-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[com_fields] field layout called 4 times even though automatic display is set to 0 #16775
Comments
onCustomFieldsPrepareDom tests the 'show_on' option. Why not onCustomFieldsPrepareField ? There is no point to prepare a field for the site if it is only meant to be seen in the admin console. That would already take away the multiple 'preparing' of layouts in the frontend that are not needed. |
@laoneo can you please have a Look on this? |
Can you show me exactly which layout is called 4 times? There are layouts in use to create the HTML value for the field and layouts which are used for automatic display. |
I don't understand the distinction you are making. I am talking about I came upon this by creating my own plugin. Thank you! |
That's why I was asking. This layout is called to create the |
I understand that. What I don't understand is the fact that, when displaying fields on the site (frontend), all fields are selected, 'prepared' then removed if set to 'no show'. Even if they are only meant to be shown on the administrator side only. When creating a new custom field, are we supposed to create 2 layouts then? |
That is something I did not notice sooner, I just noticed it while creating a new field. |
Yes |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16775 |
closed as duplicate Report #17889. Thanks for Hint @Quy. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16775. |
Steps to reproduce the issue
Instantiate any custom field (of type 'text' for instance), set the 'automatic display' to 'no'.
Set a value for this field in an article.
Create a menu item for that single article.
Load the page in the frontend for that menu item.
Expected result
The custom field value should not show.
Actual result
The custom field value does not show, yet the layout file /tmpl/the_custom_field.php has been called 4 times.
System information (as much as possible)
Joomla 3.7.3 beta, PHP 7.1.0
Additional comments
Preparing the values in getFields() from the helper file is the issue, I think. Fields are 'prepared' before being removed from the list of fields to display.
Therefore, any code that is used to 'prepare' the value in the layout of the field is called multiple times rather than being done only once (or not at all when dynamic display is set to 0).
That means, if you need lo load an external script library for your custom field, for instance, the library will be loaded on the page even though the field does not show.
The text was updated successfully, but these errors were encountered: