Flexicontent Module - Fields loading bug

More
12 years 6 months ago #31680 by maximus8891
FLEXIcontent version 2.0.0 RC9a (r1551)
I believe this issue hasn't been addressed in further commits, so it doesn't matter if it is the latest version.

I set up a fleximodule for a page. It displays items from a category. Each item has an image field and a minigallery field.
I set up (in module) to show the image field as an image source. And I turn off "display fields" for standard and featured items.

The problem is this setup adds to the document scripts of minigalleries of each item.

Code:
if ( !isset($item_field_arr[$item->id][$field->id]) ) { $item_field_arr[$item->id][$field->id] = 1; $css = " #$htmltag_id { width: ".$w_l."px; height: ".$h_l."px; margin-".$marginpos.": ".(($marginval+8)*$series)."px; } "; if ($thumbposition==2 || $thumbposition==4) { } else if ($thumbposition==1 || $thumbposition==3) { } else { // inside TODO } $document->addStyleDeclaration($css); $otheroptions .= ($otheroptions?','.$otheroptions:''); $js = " (function($){ $(document).ready(function() { $('#article-gallery').galleryView({ panel_width: 620, panel_height: 350, frame_width: 48, frame_height: 48, panel_scale: 'crop', frame_gap: 5 }); }); })(jQuery); "; $document->addScriptDeclaration($js); }

The reason for this behavior is mod_flexicontent/helper.php 434 line
FlexicontentFields::getFieldDisplay($row, $midata->name, null, 'display', 'module');
it loads image from the field for the item

this method is defined in com_flexicontent/classes/flexicontnet.fields.php
It contains:
Code:
if (!isset($item->fields)) { // This if will succeed once per item ... because getFields will retrieve all values // getFields() will not render the display of fields because we passed no params variable ... $items = array(&$item); FlexicontentFields::getFields($items, $view); }

There is no reason for isset($item->fields) to be true, as I set not to load fields.
And clearly eventually FlexicontentFields::getFields($items, $view) loads every field for an item even if I didn't want it to. Including the minigallery field, which though doesn't produce field output, but adds unnecessary scripts to the document.

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

More
12 years 6 months ago #31682 by ggppdk
No this code will
- retrieve field values of all item fields (* done once per item and has very small cost)
- will ONLY render the requested field, NOT all item fields !!!

This is because :
FlexicontentFields::getFields()
-- render fields in template positions (we have not given any),

-- only way that above code will render ALL item fields (including Minigallery field) is because you have set (in Global configuration) "Render fields HTML" to be "Always"

Other reasons for minigallery being rendered are:
-- you have enabled skip empty fields filtering in the module and you have added the minigallery field
-- some other module or FLEXIcontent view is rendering the minigallery field


A note:
Code compared to v1.5.5 has been optimized a lot , but there is always room for improvement and we plan to do profiling in future versions

Regards


-- 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.

More
12 years 6 months ago #31683 by maximus8891
"Only when needed" option has solved the issue. Thank you very much!

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

More
12 years 6 months ago #31684 by ggppdk
If you had this parameter enabled it could be because you used fields in custom category / item Template Layout without specifically saying that you need them

To specifically say that you need an field HTML to be created you
-- either put it in "renderOnly" position of you category / item Template Layouts
-- or use FlexicontentFields::getFieldDisplay() to create it

Read more here:
Upgrading custom Templates to work in v1.5.6+


-- 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.

More
12 years 6 months ago #31695 by maximus8891
I use FlexicontentFields::getFieldDisplay() to render fields, but didn't know about the purpose of renderonly position. Nice solution!

I wonder if there is a legible way to render a whole item (core and custom fields) within a different component. With minimum information being the item ID.

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

More
12 years 6 months ago #31696 by ggppdk
Yes, just a few lines of code to render the item view:

Read our faq article to get the code:
How to render item view in custom code


-- 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.369 seconds
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
Save