1

i need to show items tags into class of this item in category blog view.

enter image description here

This blog_item.php doesnt show items tags:

<?php

defined('_JEXEC') or die;

$params = $this->item->params;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$canEdit = $this->item->params->get('access-edit');
$info    = $params->get('info_block_position', 0);
$assocParam = (JLanguageAssociations::isEnabled() && $params->get('show_associations'));
?>
<div class="realizace_box <?php echo JLayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags); ?>">
    <h2><a class="realizace_link" href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); ?>"><?php echo $this->escape($this->item->title); ?></a></h2>
    <a class="realizace_link_img" href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); ?>"><?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?></a>
</div>

Somebody know why?

0

There are a variety of possibilities of why it's not doing what you want. If you haven't overridden the tag layout then I presume that your template override is not working because if it was then you would see a linked ul list invalidating your html.

If you have changed the tag layout then the problem might be there. Either way then following should hopefully help you debug your problem.

Your blog_item.php should be at: /templates/yourtemplate/html/com_content/category/blog_item.php

    // This will show you the raw values in the tags
    echo '<pre>' . print_r($this->item->tags->itemTags,1) . '</pre>';

    // This will render a list default formatted: ul > li > a 
    echo JLayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags);

    // This will extract the aliases which should be safe to use as classes
    $tags = [];
    foreach ($this->item->tags->itemTags as $tag) {
        $tags[] = $tag->alias;
    }

    ?>
    <div class="realizace_box <?php echo implode(' ',$tags); ?>">
| improve this answer | |
  • For anyone preferring a functional iteration, the loop can be replaced with array_column() like this: 3v4l.org/Bk9AY – mickmackusa Oct 15 at 22:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.