Creating Article Custom Fields - Part 1
This article will illustrate how to add custom fields to any page type in the Joomla! framework.
Core Joomla! extensions that have their own custom fields are:
- Articles
- Categories
- Users
- Contacts
We will show how to create and implement these custom fields directly into a module, category page, and custom (pre-made) layouts using real use cases found in this template.
Create New Article Custom Field
Creating a basic custom field (from the Admin Dashboard):
- Content > Field Groups > New
- We are going to title it 'Pricing'
- Save and Close
- Content > Fields > New
- Title it 'Price'
- Select Filter 'Text'
- Click on the 'Options' tab
- Under 'Display Options', find the 'Automatic Display' field
- Select 'Do not automatically display'
- Save & Close
Create Article Layout Override
- System > Site Templates
- Select your active template (Site example is My Template)
- Select the 'Create Overrides' Tab
- Components> com_content > article (click)
- This will create a new layout titled 'default' in your '/templates/html/com_content/article' directory
- Rename this file to 'price' so the filename should be 'price.php'
Create New Article With Override
- Content > Articles > New
- Add a title 'Price Example'
- Select the 'Options' Tab
- Find 'Layout' Field and select the new layout you created: 'price'
- Select the 'My Template' Tab
- Find the 'Price' field you created earlier and enter '$450'
- Save & Close
Conclusion
After following the steps above, the following items should be completed before moving to the next article:
- Article custom field group titled 'Pricing'
- Article custom field titled 'Price'
- Article layout override named 'price.php'
- New article using the 'price' layout file & a value of '$450' in the 'Price' field under the 'Pricing' tab