Hi. How can we help?

Custom Fields

Last updated: 20 April 2022
In addition to Joomla's built-in custom fields being supported within TEXTman, you can also create custom fields and display their values using a template override.

In this tutorial, we'll guide you through how to create your own custom fields.

  1. Add a price field in the TEXTman article form.
  2. Display the price field's value on the article in the frontend.

Create template overrides

To add pricing information in the article you need to create some template overrides.

Front-end

You need to create two template overrides for the front-end of your website:

  • One where editing takes place (TEXTman article form)
  • One for displaying the Joomla article

Create the following new directories in your template's html directory called com_textman and com_content:

/templates/[template_name]/html/com_textman/article/
/templates/[template_name]/html/com_content/article/

Copy the following files into these new directories respectively:

/components/com_textman/views/article/tmpl/form_content.html.php
/components/com_content/views/article/tmpl/default.php

Back-end

Assuming you are using the default Joomla 4 admin template, which is Atum. (for Joomla 3 the default admin template is called Isis)

Create a new directory in your template  HTML directory called com_textman:

/administrator/templates/atum/html/com_textman/article/

Copy the following into this new directory:

/administrator/components/com_textman/views/article/tmpl/form_content.html.php

Edit form layouts

Use the "parameters" property of the article entity to store the price information.

Open the following layout files in administrator:

/administrator/templates/atum/html/com_textman/article/form_content.html.php

and frontend

/templates/[template_name]/html/com_textman/article/form_content.html.php

Place the following code somewhere inside the <form> tag:

<? //price ?>
<? if ($article->isParameterizable()): ?>
    <div id="k-js-commerce" class="k-tab">
        <div class="k-form-group">
            <label for="param_price"><?= translate('Price') ?></label>
            <input class="k-form-control" type="text" name="parameters[price]" id="param_price" value="<?= $article->getParameters()->price ?>" />
        </DIV>
    </div>
<? endif ?><br>

Show the price information

Open this frontend template file:

/templates/[template_name]/html/com_content/article/default.php

Place the following markup where you would like to show the price:

<dl class="commerce-container">
    <dd class="field-entry ">
        <span class="field-label ">Price: </span>
        <span class="field-value"><?= $params->get('price') ?></span>
    </dd>
</dl><br>