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 '';