How far can you go with Custom Fields
by Marc Dechèvre: https://www.woluweb.be — all presentations: https://slides.woluweb.be
This presentation was made at
- JoomlaDay USA 2025 #jday25usa
1 History
- Custom Fields introduced in Joomla 3.7 (on 25 April 2017) txs to Allon Moritz (CH)
- Probably the best feature of the last 10 years!
- Very interesting & powerful because
- it is transversal because it can be used
- in core for
- Articles (most common usecase)
- Categories
- Users (so you can enrich user profiles)
- Contacts
- in any third-party, which has simply to “trigger” the Custom Fields. Example:
- DPCalendar
- J2Commerce (ex J2Store)
- in core for
- they are simple & tiny plugins
- so beyond the 16 native Custom Fields
- there are already plenty of third-party Custom Fields out there
- it is easy to create yours by duplicating an existing one and tweaking it
- it is transversal because it can be used
Having Custom Fields in core is a competitive advantage of Joomla (see for example the drama around WordPress and WPEngine and its impact for the ACF plugin…)
2 Resources
- The origins
- J&Beyond 2016 : “Custom Fields in Joomla for developers” by Allon Moritz - https://youtu.be/7ikOaOKyo6s?si=_dHKYQsIsozvkfg5
- A few years ago, I contributed a Series of 8 articles in the Joomla Community Magazine (it was still J3 back then but 95% of the content is still valid)
- Custom Fields - Episode 1: How far can we go with Joomla! and Custom Fields?
- Custom Fields - Episode 2: how to manage your Custom Fields
- Custom Fields - Episode 3: all the parameters one can wish for
- Custom Fields - Episode 4: a step by step tutorial
- Custom Fields - Episode 5: List of Resources
- Custom Fields - Episode 6: Make more with extensions
- Custom Fields - Episode 7: one Custom Field to rule them all
- Custom Fields of Type Subform ● one CF to rule them all
- An overview article
- in the “Explore the Core” series
- for CMS Africa 2019
- An article explaining how to customize the Smart Search Results Page… including adding Custom Fields
- Sync’ between Joomla Custom Fields & external sources
- summary: what about using Joomla Custom Fields to synchronise data from other sources (like open-data in JSON-format for example)?
- https://slides.woluweb.be/cf-sync/
- Custom Fields ● Custom Fields & OpenStreetMap
- summary: the goal is to create and assign an OpenStreetMap Custom Field to one or several categories. So each article (being Members, Events, whatever) will be geolocalized. And based on this we will create a global OpenStreetMap module showing all the locations.
- https://slides.woluweb.be/jab20/
- Joomla Web Services (including Custom Fields)
- historical version in the Joomla Community Magazine
- https://magazine.joomla.org/all-issues/march-2023/playing-with-the-joomla-api-part-1
- https://magazine.joomla.org/all-issues/april-2023/playing-with-the-joomla-api-part-2
- https://magazine.joomla.org/all-issues/may-2023/playing-with-the-joomla-api-part-3
- https://magazine.joomla.org/all-issues/june/playing-with-the-joomla-api-part-4
- latest version
- historical version in the Joomla Community Magazine
- Around 100 gems for Joomla 4 & 5 I can’t live without
- latest version: https://slides.woluweb.be/gems/, in particular this section https://slides.woluweb.be/gems/#custom-fields
- originally published in the Joomla Community Magazine: https://magazine.joomla.org/all-issues/february-2023/more-than-30-gems-for-joomla-4-i-can-t-live-without
- Last but not least, Nadja Lamisch wrote in March 2025 a very intersting article showing how you can use the Smart Search to filter a.o. on Custom Fields
3 List of available Custom Fields
- 16 native Custom Fields
- third-party Custom Fields
- see in particular
- my personal pick
- Advanced Custom Fields by Tassos - https://www.tassos.gr/joomla-extensions/advanced-custom-fields
- extra fields
- display conditions! (“ACF Options” tab when editing a Custom Field)
- Regular Labs Articles - https://regularlabs.com/articlesfield
- link
- reverse link
- JFilters - https://blue-coder.com/jfilters
- YOOtheme - https://yootheme.com/page-builder
- fetches Custom Fields dynamically
- third-party extension for YOOtheme: ZOOlanders Essentials https://zoolanders.com/, with ao
- Composable Sources
- Display Conditions
- …
- Displays Joomla custom fields in backend item list - https://extensions.joomla.org/extension/alter-fields/
- Advanced Custom Fields by Tassos - https://www.tassos.gr/joomla-extensions/advanced-custom-fields
- Options in Custom Fields - some were added over time
- Showon
- examples:
nameofcustomfield:1[and]blabla:2
- note: atm if using in subform should use field id (and not name)
- illustration: we set
joomladay:usa
in the configuration and then if the user selects “JoomlaDay USA” then the “List” Custom Field shows
- examples:
- note about front-end rendering if you left a Value for a field which was filled in when visible but is now supposed to be invisible
- Heading for certain types of Custom Fields like List (= dropdown)
- Form Layout for certain types of Custom Fields like List (= dropdown). See the difference below between
HTML select
andEnhanced Select
- classes : label class, display class, value class
- prefix / suffix
- make searchable
- …
- Showon
4 Tips
- add a Description to the Field Group to give clear instructions to your users
- for a Custom Field of type Calendar, you can type “now + 1 year” or “today - 7 days” as Default value
- Custom Field of Type SQL can be used for very advanced things
- we could fetch a list of Articles of a given Category (to make links between Articles) to avoid using a third-party extension
- in the following example there is an Article Custom Field fetching the list of Contacts… and each Contact has itself 3 Custom Fields (txs to Adam Melcher for this example taken from his Coding demo site at #jd25usa)
select id as value, name as text from #__contact_details where published = '1' order by ordering
- different ways to “filter” past/future Events (typically Articles for Events having of course an Event Date)
- simply by using Start Featured and End Featured!
- https://alexrevo.pw/product/revo-lockpick-plugin.html was a solution to have “now” and “today” in YOOtheme, but
- not compatible any more with YTP 4.x
- no new version by Alex and no equivalent elsewhere
- but good news for YOOtheme users: hopefully in YTP4.6 which will be released at autumn 2025 there will be a native possibility to filter dynamically on
[date] > or < NOW
… and that Date can be a Calendar Custom Field of course - CCC Timewarp by Elisa (Scheduled Task to move Articles from a Category to another, like Future to Past)
- with ZOOlanders Essentials => Timestamp : https://docs.zoolanders.com/essentials-for-yootheme-pro/datetime
- one precision though: if you set a limit of 20 items on which you put a Timestamp condition, it means that in the end one might end up with anything between 0 and 20 items which are really displayed in order to have a “real” filter playing “before” the first 20 items are fetched then YOOtheme needs to add that feature (maybe coming for YTP 4.6 in Autumn 2025)
- [ using a Custom Field with “now” as Default. Note that this solution also requires ZOOlanders Essentials ]
- in order to create an Access Condition for each Item, checking if “CF Event Date” > “CF NOW” (both being of course in same format, like Ymd for example)
- can create a Custom Field of Type Calendar and put “now” as Default
- drawback is that if some concerned Article is Saved after that, the “now” is no more dynamic but is the Date of Saving
- workaround: if Articles are only edited in the Backend, in the Options Tab, select “Editable only in Frontend” (or the other way round). Then the Custom Field always reflects “now”
- can create a Custom Field of Type Text and set Default content as {shortcode} and with a little Content Plugin (published by @SMACKit on 2025.03.16), which replaces the shortcode by “now” in Ymd format. Sources:
- simply by using Start Featured and End Featured!
- alternate layout for Custom Field itself
- https://regularlabs.com/blog/1360-how-to-create-an-alternate-layout-for-custom-fields-in-joomla
- for simple example with Custom Field of type URL where we want
- to remove
https://
from text (visually not nice) - to give a button style
- to remove
- in classical overrides (for Article views for example) we can call Custom Fields
- the classical way (in PHP calling by ID or by Name)
- or even put simply
{field ID}
(just like you can put directly this shortcode in Article) - for views where Custom Fields are not even available (like the Smart Search), you can add the following code to make them available
use \Joomla\Component\Fields\Administrator\Helper\FieldsHelper; // makes the FieldsHelper available in our override
$myCustomFields = FieldsHelper::getFields('com_content.article', $this->result, true); // creates a variable which will contain all CF of the current article. The True will allow us to render the value instead of the rawvalue
$myCustomFieldsById = \Joomla\Utilities\ArrayHelper::pivot($myCustomFields, 'id'); // we use a pivot on id so that we can easily use the id to access every CF by its ID
<p><?php echo $myCustomFieldsById[10]->rawvalue; ?></p>
- web services
- to make your content (including Custom Fields) available thanks to web services
- to import Custom Fields via web services (see links to the presentations above)
- to make your content (including Custom Fields) available thanks to web services
- front-end editing
- allow editing in front-end (ACL) - we usually adapt the ACl at the Field Group level so that we don’t have to do it individually for each Custom Field
- facilitating content Edition / Creation
- native: Custom Fields appear on the Tab. The name of Tab is the Field Group (if defined)
- Convert Forms (txs to its very easy New Content Task) or RS Forms for Article Creation with a simpler form than Joomla’s native form
- override
edit.php
if you want another layout https://www.dr-menzel-it.de/blog/override-challenge-beitrag-einreichen-im-frontend - a custom
edit.php
file by Category : https://github.com/ttc-freebies/custom-edit-forms-per-cat
- custom user.css to have icon + background-color color on the Custom Fields Tab when editing
- back-end
:root {
--cf: hsl(357 60% calc(var(--lightness) - 10%));
--cf-hover: hsl(357 60% calc(var(--lightness) - 5%));
--cf-selected: hsl(357, 60%, var(--lightness));
}#myTab button[aria-controls*="fields"] {
background: var(--cf);
color: white; /* in Dark Mode the color is white by default. But in Light Mode, if the background-color is dark, white is better for text */
}
#myTab button[aria-controls*="fields"]:hover {
background: var(--cf-hover);
}
#myTab button[aria-controls*="fields"][aria-expanded="true"] {
background: var(--cf-selected);
}
#myTab button[aria-controls*="fields"]:before {
content: url(/images/assets/cubes.svg);
display: inline-block;
width: 15px;
height: 15px;
margin-right: 5px;
}
@media (prefers-color-scheme: dark) {
#myTab button[aria-controls*="fields"]:before {
filter: invert(100%);
} }
- front-end
:root {
--cf: hsl(357 60% calc(var(--lightness) - 10%));
--cf-hover: hsl(357 60% calc(var(--lightness) - 5%));
--cf-selected: hsl(357, 60%, var(--lightness));
}[aria-controls*="fields"] {
joomla-tab buttoncolor: white;
background: var(--cf);
}
[aria-controls*="fields"]:hover {
joomla-tab buttoncolor: white;
background: var(--cf-hover);
}
[aria-controls*="fields"][aria-expanded="true"] {
joomla-tab buttoncolor: white;
background: var(--cf-selected);
}
[aria-controls*="fields"]:before {
joomla-tab buttoncontent: url(/images/assets/cubes.svg);
display: inline-block;
width: 15px;
height: 15px;
margin-right: 5px;
filter: invert(100%);
}
- in the YOOtheme context using “after display title” or “before display content” for example
- in order to have the Joomla “rendering” of the Custom Field (and not YOOtheme rendering the raw value of the Custom Field)
- in order to be able to display several Custom Fields in a single Dynamic Fied (typically Meta)
- use of Custom Fields in Acymailing
- simple usecase like on https://www.festivalmusiq3.be (additional tip: we added some CSS to our newsletter so that the text in bold and in italic in the newsletter would have a different background)
- advanced usecase by Laura Gordon where she needed to combine several Custom Fields in a certain format. There the solution was to simply create a new ad hoc Custom Field which is filled automatically when Saving the Article thanks to a little custom-made plugin (
onContentAfterSave
)
- simple usecase like on https://www.festivalmusiq3.be (additional tip: we added some CSS to our newsletter so that the text in bold and in italic in the newsletter would have a different background)
- YOOtheme has a core version of the related articles that’s based on tags / categories. ZOOlander Essentials extends it if you have Regular Labs related articles custom field plugin active on your site
- link to the discussion: https://discord.com/channels/1024977853126823937/1024977853655294004/1362491119379812416
- Tanja from webman.de suggested me this
- We have an override for the fields render.php and field render.php to control the output of the fields.
- So we e.g. use After Title to display the fields in a table, and Before Content to display the fields as an Accordion.
- In the article override we use the plugin events to place the fields where we want to have them, e.g. echo $this->item->event->afterDisplayTitle;
- Here are some links to see in production:
- https://eltra-trafo.de/produkte/transformatoren/steuertransformatoren/stv-einphasen-steuertransformator-mit-vielfachspannung - Used as table
- https://ring-mosel.de/weingueter/weingut-bastgen - Used as table
- https://lames-container.de/container-kaufen/buero-aufenthaltscontainer-kaufen/1310-20ft-buerocontainer-mit-gastherme - Used as table and as usps (two different positions)
- https://helmut-meeth.com/produkte/fenster/sanierung/ad-ab103 - Used as usps and accordion (fields are type editor)
- since Joomla 5.2 “inception” is possible. With other words, you can have natively Subforms within Subforms (also: YOOtheme manages it). Good to know: Phoca Collapse System Plugin is a Joomla! CMS Plugin. It adds the ability to hide Joomla subform content. So that subforms can be better sorted. It can be even used for menu links and articles: https://www.phoca.cz/phoca-collapse-system-plugin
- automation
- there is currently a group of Joomlers working on the integration of Joomla with Zapier… which will include Custom Fields
- during his session today about Automation, Eoin Oliver showed that Joomla is already integrated with Make.com… which includes Custom Fields. So you can for example have Make read Airtable and add/update Articles in Joomla using the web services
5 laplateforme.be, a website exploiting Custom Fields to the max
See https://www.laplateforme.be where I exploit Custom Fields to the max. :)
5.1 Context
- ~1000 Articles with 72 Custom Fields for 8 Field Groups + Filters on 13 Custom Fields
- but still super performant (see Lighthouse score hereafter)
5.3 Exploiting Joomla’s native features
- colored Tabs for edition in the back-end and front-end (see screenshot above)
- alternate layout for
- video player (based on Custom Fields containing the video ID)
- for the DIV containing the CF like for Filmography (1 Card for each film… but needed to wrap that with a
<div>
with somegrid
classes)
6 Potential improvements for the future
- Tom van der Laan has prepared a Custom Field of Type “Floating” (with a Custom Field of Type Integer you could not put a price like € 4.55 or a weight like 76,4 kg)
- Laura Gordon wrote recently on Mattermost: “I have made several ‘requests’ for J6, but I don’t think I got any bites… anyone interested in adding these great features to J6?”
- https://github.com/joomla/joomla-cms/issues/45022 - versioning custom fields
- https://github.com/joomla/joomla-cms/issues/45023 - batch add category for custom fields
- https://github.com/joomla/joomla-cms/issues/45025 - create a ‘class’ at the group level for custom fields
- https://github.com/joomla/joomla-cms/issues/45026 - batch change authors for categories / articles so you don’t get orphan records
- other improvements coming
- Custom Field of type Media : generalization ie being able to use any Media and not only Images
- current solution: https://slides.woluweb.be/gems/#allowing-documents--pdf-etc--in-the-custom-field-of-type-media
- future native solution
- Custom Field of type Media : generalization ie being able to use any Media and not only Images
- core hack by Benjamin Trenkle to make Custom Fields more performant
- put
int(10)
instead ofvarchar(255)
asType
for Columnitem_id
in the Structure of Table#_fields_values
in the database (Note the current Comment forvarchar(255)
:Allow references to items which have strings as ids, eg. none db systems.
). Makes Custom Fields so much faster. - works with core field. If 3rd party Custom Field check if Text is used (so keep track of this hack if implemented)
- maybe improvement for J6?
- put
- Robbin’s suggestion during JoomlaDay USA : enrich Custom Field of Type Text so that we can choose whether it is a Paragraph, H1 etc
7 Get in touch
Marc Dechèvre | @woluweb
+32 474 37 13 12 | +32 2 772 58 69
https://www.woluweb.be/contact
Other presentations