? ?

Pending

User tests: Successful: Unsuccessful:

avatar GeraintEdwards
GeraintEdwards
4 Mar 2017

The custom fields plugin is a welcome addition to Joomla but its usefulness is limited by a lack of configurability.

For instance you can only display custom fields in com_content within the single article view.

This PR adds a new config option to config.xml for com_content to allow the site admin user to choose other contexts where they may wish the fields to be available or displayed e.g. for com_content.featured. The mechanism can easily be extended to other components using the fields plugin.

The PR also reduces DB queries in "list views" when custom fields are not required.

Summary of Changes

  1. Adds config option to com_content to allow user to select where custom fields should be displayed
  2. Adds code in fields plugin file to use this config option
  3. Adds required language strings

Testing Instructions

Open com_content config and on Integrations tab select 'Featured articles view' as one of the output contexts for custom fields.

Expected result

Featured articles page will now show custom fields.

avatar GeraintEdwards GeraintEdwards - open - 4 Mar 2017
avatar GeraintEdwards GeraintEdwards - change - 4 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Mar 2017
Category Administration com_content Language & Strings Front End Plugins
avatar zero-24 zero-24 - change - 4 Mar 2017
Labels Added: ? ?
avatar zero-24
zero-24 - comment - 4 Mar 2017

@GeraintEdwards i have just fixed the codestyle errors.

avatar Bakual
Bakual - comment - 4 Mar 2017

For instance you can only display custom fields in com_content within the single article view.

That's not true. The featured view as well as category view will show the fields as well.

This PR adds a new config option to config.xml for com_content to allow the site admin user to choose other contexts where they may wish the fields to be available or displayed e.g. for com_content.featured. The mechanism can easily be extended to other components using the fields plugin.

Please don't check component parameters within the fields plugin. That plugin shouldn't be aware of the components and the components should be aware of the fields plugin.

If you want to limit the fields functionality to certain views, it's probably best to use overrides anyway, but if you really want to add such a parameter, it should go to the component helper. Look at the validateSection method in https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_content/helpers/content.php#L228
If you return null there, the fields will not be parsed. So if you add the parameter there, you can already control fields (and all future code which may use that method).
This way you don't have to mess with the fields plugin at all.

avatar GeraintEdwards
GeraintEdwards - comment - 6 Mar 2017

My mistake - sorry. My code base wasn't up to date and I hadn't picked up the changes to validateSection in the last few weeks :(

avatar GeraintEdwards GeraintEdwards - close - 6 Mar 2017
avatar GeraintEdwards GeraintEdwards - change - 6 Mar 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-03-06 14:43:12
Closed_By GeraintEdwards

Add a Comment

Login with GitHub to post a comment