Joomla Custom Fields — Adding and Managing Custom Content Fields
In this tutorial, you'll learn how to create and manage Joomla custom fields — adding extra data to articles, users, contacts, and categories using field types like text, editor, image, file, calendar, checkbox, and color, and displaying them in your template.
What You'll Learn
- What custom fields are and why they are useful
- Creating field groups to organize fields by purpose
- Using all field types: Text, Textarea, List, Checkbox, Radio, Media, URL, Editor, Calendar, Color, Image, User, Integer, Repeatable, SQL, Subform
- Configuring field settings per type
- Displaying custom fields in articles automatically
- Using custom fields on user profiles, contacts, and categories
- Rendering fields in template overrides with PHP
Why It Matters
Default Joomla articles have a fixed set of fields: title, alias, intro text, full text, category, and tags. But real-world content needs more. A recipe site needs "cooking time" and "servings." A real estate site needs "price" and "bedrooms." A team page needs "job title" and "phone number." Custom fields let you add these without modifying core code. They were introduced in Joomla 3.7 and have become one of the most powerful features for building custom content types.
Real-World Use
A job board built with Joomla needs each job listing to have: location (list), salary range (text), job type (radio: full-time, part-time, contract), application deadline (calendar), and company logo (image). Using custom fields, the site adds all of these to the standard article form. No extension needed. The fields appear in the article automatically. The template overrides apply custom styling. The job board launches with a professional listing format using only core Joomla features.
Learning Path
flowchart LR A["User Groups"] --> B["Custom Fields"] B --> C["Joomla API"] C --> D["Database Maintenance"] D --> E["Go-Live Checklist"] classDef current fill:#38bdf8,color:#0f172a,stroke-width:2px class B current
What are Custom Fields?
Custom fields are extra data fields you can attach to Joomla content types. They were introduced in Joomla 3.7 and are supported in Joomla 4 and 5.
Supported content types:
| Context | Content Item | Field Type Support |
|---|---|---|
| com_content.article | Articles | All field types |
| com_users.user | User profiles | All field types |
| com_contact.contact | Contacts | All field types |
| com_content.category | Categories | All field types |
When you add a custom field to articles, it appears in the article edit form. When the article is saved, the field value is stored and displayed in the article output.
Field Groups
Field groups help you organize related fields.
- Go to Content > Fields (or Components > Fields for other contexts)
- Click the Groups tab
- Click New to create a group
- Example groups:
| Group Name | Context | Purpose |
|---|---|---|
| Article Metadata | com_content.article | SEO fields, reading time |
| Recipe Details | com_content.article | Cooking time, servings, ingredients |
| User Profile | com_users.user | Phone, department, location |
| Contact Info | com_contact.contact | Office hours, department |
Creating a Group
Title: Job Listing Fields
Type: com_content.article
Description: Extra fields for job listings
Published: Yes
After creating the group, you add fields to it.
Field Types
Joomla offers many field types. Each is designed for a specific kind of data.
Text
Simple single-line text input. Best for short values like "Price" or "Author."
| Setting | Value |
|---|---|
| Type | Text |
| Size | 40 |
| Max Length | 255 |
| Filter | Raw (no filtering) or specific filter (e.g., HTML safe) |
| Default Value | (optional) |
<!-- Rendered output -->
<input type="text" name="custom_field_price" value="299" size="40" maxlength="255" />
Textarea
Multi-line text input. Best for longer values like "Description" or "Notes."
| Setting | Value |
|---|---|
| Type | Textarea |
| Rows | 10 |
| Cols | 60 |
| Filter | Raw or HTML |
List
Dropdown selection. Best for choosing one option from a set.
| Setting | Value |
|---|---|
| Type | List |
| List Options | Option 1=value1, Option 2=value2, Option 3=value3 |
| Multiple | No |
Checkbox
Single checkbox for boolean values.
| Setting | Value |
|---|---|
| Type | Checkbox |
| Value | 1 (when checked) |
| Default | 0 (unchecked) |
Multiple Checkbox
Multiple checkboxes for selecting several options.
| Setting | Value |
|---|---|
| Type | Multiple Checkbox |
| Checkbox Options | Option 1=value1, Option 2=value2 |
Radio
Radio buttons for mutually exclusive options.
| Setting | Value |
|---|---|
| Type | Radio |
| Radio Options | Full-time=full, Part-time=part, Contract=contract |
Media
File picker that opens the Media Manager.
| Setting | Value |
|---|---|
| Type | Media |
| Directory | images/ |
| Preview | Yes |
URL
URL input with validation.
| Setting | Value |
|---|---|
| Type | URL |
| Relative | Yes (allow relative URLs) |
| Scheme | http, https |
Editor
Full WYSIWYG editor (TinyMCE).
| Setting | Value |
|---|---|
| Type | Editor |
| Buttons | Yes (show editor toolbar) |
Calendar
Date/time picker.
| Setting | Value |
|---|---|
| Type | Calendar |
| Show Time | Yes or No |
| Format | %Y-%m-%d |
Color
Color picker that returns hex values.
| Setting | Value |
|---|---|
| Type | Color |
| Default | #000000 |
Image
Image with alt text.
| Setting | Value |
|---|---|
| Type | Image |
| Directory | images/ |
| Alt Field | Show (shows alt text input) |
User
User selection from a dropdown of registered users.
| Setting | Value |
|---|---|
| Type | User |
| Multiple | No |
Integer/Number
Numeric input with range validation.
| Setting | Value |
|---|---|
| Type | Integer |
| First | 0 |
| Last | 100 |
| Step | 1 |
Repeatable
A group of subfields that can be repeated. Best for tabular data.
| Setting | Value |
|---|---|
| Type | Repeatable |
| Subfields | [field specifications in JSON] |
SQL
Dynamic dropdown populated by an SQL query.
| Setting | Value |
|---|---|
| Type | SQL |
| Query | SELECT id, title FROM #__categories WHERE published = 1 |
| Value Field | id |
| Text Field | title |
Subform
Embed a group of reusable fields within another form.
| Setting | Value |
|---|---|
| Type | Subform |
| Subform Fields | [reference to another field group] |
Creating a Field
- Go to Content > Fields (or Components > Fields)
- Click New
- Configure:
| Tab | Setting |
|---|---|
| General | Title: "Price", Type: Text, Group: Job Listing Fields |
| Options | Size: 40, Max Length: 255, Filter: Raw |
| Publishing | Status: Published, Access: Public |
Assigning to Context
The field must be assigned to a context:
| Context | Effect |
|---|---|
| com_content.article | Appears in article edit form |
| com_users.user | Appears in user profile edit form |
| com_contact.contact | Appears in contact edit form |
| com_content.category | Appears in category edit form |
Displaying Custom Fields in Articles
By default, custom fields appear automatically in the article output, below the full text and above the tags.
Order of Display
Fields are displayed in the order they appear in the Fields manager. You can reorder them by dragging.
Template Override for Custom Fields
If you want full control over field display, override the layout:
- Copy
/components/com_content/tmpl/article/default.phpto/templates/cassiopeia/html/com_content/article/default.php - In the override, add field rendering:
<?php
// In template override, render custom fields manually
$fields = FieldsHelper::getFields('com_content.article', $this->item, true);
foreach ($fields as $field) {
if ($field->value) {
echo '<div class="custom-field">';
echo '<strong>' . $this->escape($field->label) . ':</strong> ';
echo JLayoutHelper::render('joomla.content.field_value', $field);
echo '</div>';
}
}
?>
Alternatively, use a layout override for the whole field display:
<?php
// Get rendered field HTML
echo JLayoutHelper::render('joomla.content.blog_style_default_item_title', $this->item);
?>
Custom Fields on Users
- Go to Components > Fields
- Set context to com_users.user
- Create fields: Phone, Department, Location, Bio
- Users see these fields when editing their profile
Custom Fields on Contacts
- Set context to com_contact.contact
- Create fields: Office Hours, Department, Specialization
- The fields appear in the contact form
Custom Fields on Categories
- Set context to com_content.category
- Create fields: Category Icon, Featured Status, Color Code
- The fields appear in the category edit form
Rendering in Template Overrides
For advanced customization, use PHP in template overrides:
<?php
// Load custom fields helper
use Joomla\CMS\Fields\FieldsHelper;
// Get fields for this article
$fields = FieldsHelper::getFields(
'com_content.article',
$this->item,
true // Only visible fields
);
// Display each field with custom markup
foreach ($fields as $field) {
echo '<div class="custom-field mb-2">';
echo '<span class="custom-field-label fw-bold">' .
htmlspecialchars($field->label) . ':</span> ';
echo '<span class="custom-field-value">' .
FieldsHelper::renderFieldValue($field, 'com_content.article') .
'</span>';
echo '</div>';
}
?>
Field Display in Feeds
Custom fields do not appear in RSS/Atom feeds by default. To include them, you need a plugin or custom feed layout override.
Common Mistakes
Not assigning a field to the correct context: A field created for com_content.article will not appear on user profiles. Always double-check the context setting.
Creating too many fields: Each field adds complexity to the article edit form. Group related fields into Field Groups and keep the total under 20 per content type.
Not setting default values: For List, Radio, and Checkbox fields, set sensible defaults. Empty fields can cause display issues in templates.
Using the wrong field type: A URL field validates URLs and may reject relative paths. A Text field accepts anything. Choose the type that validates correctly for your data.
Forgetting to render fields in template overrides: If you override the article layout, custom fields are not automatically displayed. Add the FieldsHelper::getFields() call explicitly.
Practice Questions
What content types support custom fields in Joomla? Answer: Articles (com_content.article), user profiles (com_users.user), contacts (com_contact.contact), and categories (com_content.category). Each context stores fields in the same database structure but associates them with the relevant content type.
How do you display custom fields in a template override? Answer: Use FieldsHelper::getFields('com_content.article', $item, true) to load visible fields, then loop through them with FieldsHelper::renderFieldValue() to display each field's rendered value.
What is the difference between a Repeatable field and a Subform field? Answer: A Repeatable field lets you define a set of subfields that can be repeated multiple times (like a table with rows). A Subform field embeds an entire group of fields (defined elsewhere) into another form. Subforms are more flexible for complex nested data.
Challenge: Create a complete set of custom fields for a "Recipes" content type. Include: cooking time (text), servings (integer), difficulty (list: easy, medium, hard), ingredients (repeatable field with name and amount), featured image (media), and dietary tags (multiple checkbox: vegetarian, vegan, gluten-free). Group these fields into a "Recipe Details" field group. Create 5 recipe articles with different values. Display the fields in the article output using a template override with custom CSS styling.
FAQ
Mini Project
Your task is to build a custom data solution for a job board site.
Create a field group called "Job Listing Fields" (context: com_content.article)
Create these custom fields in the group:
- Location (List type: Remote, On-site, Hybrid)
- Job Type (Radio: Full-time, Part-time, Contract, Internship)
- Salary Range (Text: "$50k - $70k")
- Application Deadline (Calendar type with Show Time = No)
- Company Name (Text)
- Company Logo (Image type, directory = images/logos/)
- Apply URL (URL type)
- Requirements (Editor type for rich formatting)
Create 5 job listing articles with values in all custom fields
Create a template override for the article layout that displays fields in a professional card layout
Style the output with CSS (use Bootstrap utility classes)
Verify fields display correctly on the frontend
Document your field configuration and template code.
What's Next
Now that you can extend content with custom fields, learn about the Joomla API:
Continue to Lesson 38: Joomla Web Services API — REST API and application endpoints.
Related lessons:
- {{< ilink "Joomla" "Joomla User Groups" }} — Control who can edit custom fields
- {{< ilink "Joomla" "Joomla Multilingual Sites" }} — Custom fields with translations
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro