1

I am using custom fields introduced in Joomla 3.7 as a way to structure articles in my Joomla 3.8.3. installation. One of my custom fields contains shortcode to be rendered by another plugin. But all I can get from displaying that field is the value of the custom field, not the rendered content.

For example:

  • custom field id = 3;
  • custom field type = text;
  • custom field value = {image}path/to/image.jpg{/image}.

In the article I call {field 3}.

The expected result would be image with url path/to/image.jpg.

The actual result is raw text {image}path/to/image.jpg{/image}.

I do not know if there is an option that I have to change to force the custom field be rendered by plugin or create an override. I have this working in my previous installation of the Joomla, but after having my server hacked the backup does not restore the expected behavior.

Edit: I forgot to mention that using just plugin short-code renders as expected so it is not a plugin, Joomla or server problem.

Can somebody please help me. Regards; Luka

0

1 Answer 1

2

The answer was given on the forum: https://forum.joomla.org/ by user effrit.

You need to create a layout override for the field. Go to Extensions => Templates => Templates. Select [YOUR-TEMPLATE] - Details and Files. Click on Create override and select Layouts => com_fields => fields. That will copy the com_field render.php into override directory of a template (path is:/templates/YOUR-TEMPLATE/html/layouts/com_fields/field/render.php). Go to Editor and select the html => layouts => com_fields => field => render.php.

Find the following string

<span class="field-value"><?php echo $value; ?></span>

and replace it with

<span class="field-value"><?php echo JHtml::_('content.prepare',$value); ?></span>

You can off course use field id to only to the override on fields that need it:

<?php if ( ($field->id == 'X') or ($field->id == 'Y') ) : ?>
    <span class="field-value"><?php echo JHtml::_('content.prepare',$value); ?></span>
<?php else : ?>
    <span class="field-value"><?php echo $value; ?></span>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy