TIPS - Using custom fields by name

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');

Alexandre ELISÉ

#Joomla technical problem solver. Focusing on secure coding and defensive cybersecurity #appsec #blueteam.#coderparlerpartager Now working @aproximito.

Get the newsletter

Super Joomlers! Get the most out of Joomla!
We hate spam as much as you do and we will not send you email without your prior consent. You can unsubscribe / resubscribe any time you want.