custom fields in joomla
TRANSCRIPT
Custom Fields in Joomla
Presented at Sydney Joomla User Group 14th June 2016
By Tim Plummer
What are custom fields?
• Allow you to add your own pieces of information to Joomla content
Joomla 3.7
• It is planned that custom fields (com_fields) will be added to Joomla core in version 3.7 later this year.– Based on DP Fields (third party extension by
Digital Peak)– https://github.com/joomla-projects/custom-fields– https://joomla.digital-peak.com/blog/198-custom-
fields-in-joomla-3-6
Concept of DP Fields
• It’s not a CCK• It’s not a standalone component• Works like com_categories• Can be integrated with third party extensions
What is DP Fields?
• Is a component and a system plugin• Extends Jform• Users JFormFields• Is MVC coded• Uses JLayouts
Installation
• DP Fields can be installed like any other third party extension
System plugin
System plugin should be automatically enabled during install
Where to find it?
Does not appear in components menuBut in article manager, you will see two new views
Creating a field
Need to enter a title, select type, and enter a label
Using custom fields
• In any article, you will now see the fields tab with your custom fields
Displaying custom fields
• If data entered in field, it will automatically appear at top of article
How to control where field appears
• To specify where in the article the field appears, you can use
{{#dpfields}} {{label}}:{{{value}}} {{/dpfields}}
To stop fields appearing twice
• Create a field with alias disable-default-rendering, type=Yes No, Default value=Yes
Now field only appears once
Inserting individual fields
• You can use the editor Insert field button if you want to insert individual fields in different places in your article rather than all together
For developer
• To integrate into your extension– Add menu item sidebar– Fields added to form during
onContentPrepareForm– Fields are saved through onContentAfterSave
event
Versioning
• No versioning in com_fields (going into core), but may be added in future. Original DP Fields does have versioning.
Something to be aware of
• After you save field the first time, the type cannot be changed.
Can I search custom fields?
• Basic search needs a join, look at the plg_search_content plugin
• Smart search is automatically supported
Questions?
Tim Plummerwww.tamlynsoftware.com
@bfsurvey