Using custom fields by name
Photo from Unsplash
Category: Blog
Hits: 2302

TIPS - Using custom fields by name

Hello super joomlers!

I know, I know. You will likely tell me that there will be conflicts by using custom fields by name because names are not necessarily unique.

But there is a solution for that. Using a naming convention for your custom fields. For example for article content custom fields you could use something like article-my-field.

Besides this convention. You can use this oneliner sample code rather than trying to memorize custom fields id by heart even if we might have written the ids down on a document it's a painful task.

Here is an attempt to simplify this task.

$fields_by_name = \Joomla\Utilities\ArrayHelper::pivot($list_of_fields, 'name');
  • Hits: 2302