?
avatar obuisard
obuisard
19 Jun 2017

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.

avatar obuisard obuisard - open - 19 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jun 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Jun 2017
avatar obuisard obuisard - change - 19 Jun 2017
The description was changed
avatar obuisard obuisard - edited - 19 Jun 2017
avatar obuisard obuisard - change - 19 Jun 2017
The description was changed
avatar obuisard obuisard - edited - 19 Jun 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Jun 2017
Category com_fields
avatar obuisard
obuisard - comment - 19 Jun 2017

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.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Jun 2017

@laoneo can you please have a Look on this?

avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Jun 2017
Status New Information Required
avatar laoneo
laoneo - comment - 22 Jun 2017

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.

avatar obuisard
obuisard - comment - 22 Jun 2017

I don't understand the distinction you are making.

I am talking about
plugins -> fields -> [field name] -> tmpl -> [field name].php

I came upon this by creating my own plugin.
[field name].php being called several times although the field is automatically displayed to 'not show' (value of 0).

Thank you!

avatar laoneo
laoneo - comment - 22 Jun 2017

That's why I was asking. This layout is called to create the value parameter of the field itself. The layout which is called for automatic display is render.php.

avatar obuisard
obuisard - comment - 22 Jun 2017

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?
One in plugins -> fields -> [field name] -> tmpl -> [field name].php and one in ?

avatar obuisard
obuisard - comment - 22 Jun 2017

That is something I did not notice sooner, I just noticed it while creating a new field.
There may be something I am missing here :)

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Aug 2017
Status Information Required Discussion
avatar Quy
Quy - comment - 1 Oct 2017

Is this a duplicate issue of #17889 with PR #17895?

avatar ggppdk
ggppdk - comment - 1 Oct 2017

Yes

avatar franz-wohlkoenig franz-wohlkoenig - change - 1 Oct 2017
Status Discussion Duplicate Report
Closed_Date 0000-00-00 00:00:00 2017-10-01 13:43:14
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 1 Oct 2017
Status Duplicate Report Closed
Closed_Date 2017-10-01 13:43:14 2017-10-01 13:43:15
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 1 Oct 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 1 Oct 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 1 Oct 2017

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.

Add a Comment

Login with GitHub to post a comment