/joomla-article-custom-field

Joomla plugin to add a custom field to a selected category

Primary LanguagePHPApache License 2.0Apache-2.0

This plugin shouldn't be used

Since joomla 3.7 this feature has been implemented in joomla core so no need to use this anymore.

#################################### #########################

Joomla article custom fields

Joomla plugin to add a custom field to a selected category. This plugin was created after this question on joomla.stackexchange.com.

##Installation

  1. download ZIP
  2. go to your admin panel and navigate to Extensions -> Manage and "Upload Package File" tab.
  3. choose the downloaded .zip file and click "Upload & Install"
  4. navigate to the plugin manager Extensions -> Plugins and search for "Content - ACF Article Custom Field"
  5. enable the plugin and select the joomla category you need apply the custom field to
  6. create a new article and select the category
  7. under the "Custom field" tab, there is a custom text field

At this point, you are able to save the custom field value in the article params.

##Display the custom field value

Create a template override for the article. In defaul.php add the following code where you want the custom field to be displayed:

<?php if ($this->item->params->get('custom_field1')) : ?>
    <div class="custom_field1">
	    <?php echo $this->item->params->get('custom_field1'); ?>
    </div>
<?php endif; ?>

Adding custom fields to the plugin

To add custom fields, you need to edit the forms/content.xml file. You can use joomla standard form field types (see here).

Here are a few examples :

###Add a custom image field:

<field
  name="custom_field_image"
  type="media"
  label="Custom image"
  description="Select a custom image"
  />

More info on the Media form field type here.

###Add a custom pdf document:

<field
  type="filelist"
  name="custom_pdf_path"
  label="Custom PDF file"
  directory="images/documents"
  filter="\.pdf$"
  hide_default="true"
  />

This will output a select element and allow the selection of pdf files in the images/documents directory. The field will store the pdf name with extension. More info on the filelist form field type here