0

How to add tags in the template of mod_tags_similar? I add custom fields and other data by this code

$db = JFactory::getDbo();
$query = $db->getQuery(true)
    ->select($db->quoteName(array('core_content_id', 'core_content_item_id', 'core_images', 'core_title', 'core_alias', 'core_created_time', 'core_catid')))
    ->from($db->quoteName('#__ucm_content'))
    ->where($db->quoteName('core_content_id') . ' IN (' . implode(',', array_column($list, 'core_content_id')) . ')');

$extraData = $db->setQuery($query)->loadObjectList('core_content_id');
$ItemDataArray = json_decode(json_encode($extraData), true);

JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fields/models', 'FieldsModel');
$field = JModelLegacy::getInstance('Field', 'FieldsModel', array('ignore_request' => true));

<?php foreach ($ItemDataArray as $ItemData) : ?>
<?php
   echo $field->getFieldValue(29, $ItemData['core_content_item_id']),true;
?>
<?php endforeach; ?>

Maybe there is a way to add tags in this way?

2
  • Some relevant guidance on querying the database with a dynamic WHERE IN(): How to Use IN Clause in Joomla Query. Also, instead of calling json_decode(json_encode($objectArray), true) to form an array of arrays, just use Joomla's loadAssocList() docs.joomla.org/… oh... and that trailing ,true on that last echo looks out of place. I won't be posting an answer, because I don't know how to resolve your question. Commented Feb 20, 2023 at 21:12
  • Thank you for your advice. But it would be better to tell me how to solve my problem. Do you know how?
    – Alines
    Commented Feb 20, 2023 at 21:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.