Joomla comes with default fields that are useful for writers. However there are sometimes that you need extra fields for enhancing your articles and improving SEO. In this article I will give you a step-by-step guide on how to create new fields without extensions in Joomla.
The best way to add new fields is by creating a plugin for Joomla. Plugins provide functions which are associated with trigger events. Joomla provides a set of core plugin events.
Let’s say you need to add a new field called ”Additional address information” to your contact form plugin. You need to access the “Forms” folder of the plugin and add your custom field there like this:
<field name="add_address_info" type="text" label="PLG_CONTENT_ADD_ADDRESS_INFO" />
Now you have your new shiny field without any extra code. To display your new field is pretty straightforward. Add the following code to your template:
<?php if ($this->params->get('add_address_info', false)) : ?> <div> <span class="contact-add_address_info"> <?php echo $this->params->get('add_address_info'); ?></a><br/></span> </div> <?php endif; ?>
Save your changes and that’s it! Your new field has been added.
This concludes Create new fields without extensions in Joomla.