FlexiFields are rendered even if they are not displayed

More
12 years 10 months ago - 12 years 10 months ago #16685 by ggppdk
The Problem:
FlexiFields are rendered(=their display is created) even if they are not displayed.
This in general is not needed* and may cause problems.

* It could be needed for a field to be always rendered to have it make the field have a side-effect, e.g. make a db update or file manipulation.
Maybe the templates should have a hidden position for fields that should be rendered but not displayed.
OR put an option to always render a field even if not displayed.

-- An example where a non-displayed field, causes problems when rendered, is the mini-gallery.
-- This mini-gallery FlexiField when rendered, it adds javascript and css to the header.
-- But the javascript will produce an error because the html of the field is not present (the field is not in the template).

Fix:
Comment out line 100-107 of components/com_flexicontent/classes/flexicontent.fields.php
To prevent them from being always rendered and then
replace at line 289-301:
Code:
for ($i=0; $i < sizeof($items); $i++) { foreach ($fbypos as $pos) { foreach ($pos->fields as $f) { ... } } }
with:
Code:
for ($i=0; $i < sizeof($items); $i++) { // 'text' item field is always used by category, render it if ($view == 'category') { $field = $items[$i]->fields['text']; $field = FlexicontentFields::renderField($items[$i], $field, $values, $method='display'); } // render flexi fields if they are present in the template foreach ($fbypos as $pos) { foreach ($pos->fields as $f) { $field = $items[$i]->fields[$f]; $values = isset($items[$i]->fieldvalues[$field->id]) ? $items[$i]->fieldvalues[$field->id] : array(); $field = FlexicontentFields::renderField($items[$i], $field, $values, $method='display'); if (isset($field->display) && $field->display) { $items[$i]->positions[$pos->position]->{$f}->id = $field->id; $items[$i]->positions[$pos->position]->{$f}->name = $field->name; $items[$i]->positions[$pos->position]->{$f}->label = $field->parameters->get('display_label') ? $field->label : ''; $items[$i]->positions[$pos->position]->{$f}->display = $field->display; } } } }
I also attach the modified file (components/com_flexicontent/classes/flexicontent.fields.php for version 1.5.5r607), please TEST and post back if it works and backup the original in case you need to restore it. I will then submit it to bug tracker.
Consider this experimental as it is a major change, e.g. with this modification something may not function properly.


-- 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...
Attachments:
Last edit: 12 years 10 months ago by ggppdk.

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

More
12 years 10 months ago - 12 years 10 months ago #16686 by ggppdk
For the FlexiContent module to work with this modification,
replace at line 100
of modules/mod_flexicontent/helper.php:
Code:
if ($use_fields) { $rows = FlexicontentFields::getFields($rows, 'module'); }
with
Code:
if ($use_fields) { $rows = FlexicontentFields::getFields($rows, 'module', $params); }


-- 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...
Last edit: 12 years 10 months ago by ggppdk.

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

More
12 years 10 months ago #16693 by micker
:o

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.393 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