[Fixed] Issue with Relation - Reverse field

More
9 years 5 months ago #51220 by MikeSantana
I found an issue with the “Relation – Reverse” type field.


-- It does not allow me to limit the items list generated to current "published" items.

I had check the field classes but it does not have a parameter to pass to limit the query to items published.

I had the situation that I have an item with a "relation" type field where I do specified to limit the relation to Published items. IT DOES WORK.
I had another type of item where I use the "relation-reverse" type field that it is pointing to my previous field.


-- However it does not have a parameter to limit my reverse to "published" items from my precious field type "relation" (mentioned above). Therefore it is generating a display with the “relation – reverse “ -> prefix text of every value, Suffix text of every value, OpeninClosing text for Fieldg text for Field, Closing text for Field.

This should not be happening if it does not find an item to be related.
I did check the "relation - reverse" field code


It is calling:
Code:
$field->{$prop} = FlexicontentFields::getItemsList($field->parameters, $_itemids_catids, $isform=0, @ $reverse_field, $field, $item);
NOTE the class does not have a parameter to limit the item state.


Then it does generate the Query:

SELECT i.*, ext.type_id, GROUP_CONCAT(c.id SEPARATOR ",") AS catidlist, GROUP_CONCAT(c.alias SEPARATOR ",") AS cataliaslist FROM jos_content AS i LEFT JOIN jos_flexicontent_items_ext AS ext ON i.id=ext.item_id JOIN jos_flexicontent_fields_item_relations AS fi_rel ON i.id=fi_rel.item_id AND fi_rel.field_id=58 AND CAST(fi_rel.value AS UNSIGNED)=31 LEFT JOIN jos_flexicontent_cats_item_relations AS rel ON i.id=rel.itemid LEFT JOIN jos_categories AS c ON c.id=rel.catid WHERE 1 AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= UTC_TIMESTAMP() ) AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= UTC_TIMESTAMP() ) GROUP BY i.id ORDER BY i.created DESC, i.title ASC



However it does not limit the Query to “state =1” which it would make sense since we should only be interested on showing active items.

It should have something like this
Code:
foreach($item_list as $result) { // Check if related item is published and skip if not published if ($result->state != 1 && $result->state != -5) continue; }


Then it is passed to:
createItemsListHTML()
to generate the display. Therefore it is too late to remove the “unpublished” items.


My solution is to update the code in
/components/com_flexicontent/classes/flexicontent.fields.php
static function getItemsList()


NOTE: the for each needs to be before checking if we have something remaining in the $item_list variable
Code:
foreach($item_list as $k=>$result) { // Check if related item is published and skip if not published if ($result->state != 1 && $result->state != -5) { unset($item_list[$k]); } } // No published related items or SQL query failed, return if ( !$item_list ) return '';

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago #51232 by ggppdk
Hello

thanks for report, and details
-- fixed in v2.2.x_branch,


Here is the description of the commit:

# Fixed getItemList helper function retrieving unpublished, trashed items.

This effects both
- relation and relation reverse frontend display
- and relation reverse display in item form.

Now by default, unless otherwise specified, the helper function will only retrieve published items, that is "Published, Published: In progress, Archived"



NOTE: The archived is included by default, despite the fact that an archived is not listed in normal views, it is still a "published" items so links to it must be displayed


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.318 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline