#649 Using Joomla Custom Fields with J2C

Posted in ‘Technical Support / Bugs’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Chris Elliott on Tuesday, 24 March 2026 08:09 UTC

Chris Elliott

I'd like to use Joomla's Content } Fields in my products to help show prefined text content against selected products.

I can see (example)

{field 1} in the article editor but its not being pulled through to the front end short/long description or specifications content.

Am I missing a trick?
Chris

Olivier

Chris,

I don't think you are missing anything. I checked our code and I don't see any mention of it for product descriptions.

It is just missing.

Right now, before the core handles it out of the box, you can use:

use Joomla\CMS\HTML\HTMLHelper;

HTMLHelper::_('content.prepare', $this->product->product_long_desc);

to any override that represents the long/full description (like view_ldesc.php or default_decsription.php) for instance.

That will force the fields to be rendered.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Chris Elliott

Hi there Olivier.

Thanks for your response, which I've given a try.I've applied the additional code to the lview_sdesk.php override:

<?php
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
HTMLHelper::_('content.prepare', $this->product->product_short_desc);
?>

<?php if($this->params->get('item_show_sdesc', 1)): ?>
<div class="product-sdesc">
<?php echo $this->product->product_short_desc; ?>
</div>
<?php endif; ?>

Sadly the fields were not pulling through.

I did some research and found the following which might (or might not) be correct!

"The reason your custom fields aren't showing up is because content.prepare processes the text, but it doesn't automatically "inject" the fields unless the Fields Plugin is specifically told to do so.

In Joomla, custom fields assigned to an article are stored in a separate property (usually $item->jcfields).

Because you are working within a J2Store view, the $this->product object might contain the article ID, but it doesn't always load the fields automatically for performance reasons.

Here is the most reliable way to display those fields in Joomla 5/6:

Updated Code with Fields Support

<?php
/**
* @package J2Store
* @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
* @license GNU GPL v3 or later
*
* Bootstrap 5 layout of product detail
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
HTMLHelper::_('content.prepare', $this->product->product_short_desc);
?>

<?php if($this->params->get('item_show_sdesc', 1)): ?>
<div class="product-sdesc">
<?php echo $this->product->product_short_desc; ?>
<?php echo HTMLHelper::_('content.prepare', $this->product->product_short_desc);?>
</div>
<?php endif; ?>

But unfortunately, even this doesn't work!

Suggestions welcome!
Chris

Olivier

Hmmm, it's not as simple as I thought. I have to investigate a bit more.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Chris Elliott

Hi Olivier,

I recognise you will have other product priorities but I wonder if you've had opportunity to dig further into this one?

c

Olivier

I am sorry for the delay Chris...

The problem is that we are not in the context of an article. Therefore the code I gave you can't work as is.

So what you may want to try:

$article = JTable::getInstance('Content', 'JTable');
$article->load($this->product->product_source_id);

echo HTMLHelper::_('content.prepare', $article->introtext);

That should do the trick.

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Chris Elliott

Forgive me Olivier.

I tried adding this to ldesc and sdesc.php but nothing is showing from a fields pov.

im probably adding to the wrong file(s)?

can you advise?

Olivier

You know what Chris, have you checked this? This could just be the answer... https://www.j2commerce.com/extensions/apps/content-custom-fields.

That totally skipped my mind...

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Chris Elliott

Aha!

I'll definitely give that one a try. I must make a list of all of these apps and extensions!

Stay Updated

Subscribe for free and be the first to know about the latest features, updates, and new additions.