I have category custom fields and I need to show these in the article (which is in the category) view.
I have used the following:
use Joomla\CMS\Factory; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; // Get the category object $customFields = FieldsHelper::getFields('com_content.category', $category, true); var_dump($customFields); This outputs as:
array(0) { } I need to output the custom fields. I have even tried the following
<div class="custom_fields"> <?php foreach ($customFields as $catfield) { echo '<div>'; echo '<h3>' . htmlspecialchars($catfield->label) . '</h3>'; echo '<p>' . htmlspecialchars($catfield->value) . '</p>'; echo '</div>'; } ?> </div> but it's only outputting as:
<div class="custom_fields"></div>