Question

I am developing a site using joomla 3.2.3 where I've been adding some tags to my joomla articles that in the articles is displayed above it's content.

For listing I use the 'Menu Item Type: Articles > Category List' and I would like to have it display the articles Tags in the list as well, e.g. like this:

[Title] [Author] [Tags]

Since joomla doesn't support this option in the article manager option to show tags in the List-Layout, I've been trying to add it to the list by editing the List-Layout files. Here I made a template override of:

com_content > Category

Which includes the list-files:

  • default.php
  • default.xml
  • default_article.php
  • default_children.php

Then I've tried modifying this file, which creates the list-layout:

.../templates/my_template/html/com_content/category/default_articles.php

To create the tag column for the list-layout I added this code in the section around line 100:

<?php if ($this->params->get('show_tags')) : ?>
   <th id="categorylist_header_tags">
         <?php echo JHtml::_('grid.sort', 'JTAG', 'tags', $listDirn, $listOrder); ?>
   </th>
<?php endif; ?>

This created and displays a 2nd column in my category list view with the header title: Tags (if set to 'show' in Article Manager Option)

And to get the tags to display in the column fields, I figured that i need to add a code for the tags in the section around line 181, where I tried adding this code:

   </td>
<?php endif; ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
   <<td headers="categorylist_header_tags" class="list-tags">
      <?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
      <?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
         <?php echo JText::sprintf('JTAG', $article->tags->itemTags); ?>
   </td>
<?php endif; ?>

This is the code I need help with, since it doesn't fully work, it only shows the text 'tags' (from the 'JTAG') in the fields, and doesn't display the article's tag from the code:

<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>

which I took from the Articles view default layout to see how the tags are rendered. But this code apperently doesn't directly work in the Category list Layout or doesn't give any effect.


Tried to take a look at this post: Article Tags shown in Article List-Layout

But have not been able to get the code in this post to work for me:

Was it helpful?

Solution

So if you look at the weblinks category layout you'll see that tags for individual links are displaywed with this code:

<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
    <?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
    <?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?>

So what you need to do is set up the $tagsData correctly changing the alias name and also making sure that the id variable is correct.

You put this inside the code for the layout of an individual item on the list meaning in the blog_item.php file possibly right after the title.

    <?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
    <?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top