Getting tag name & author details to K2 (Joomla!) Tag page

752 Views Asked by At

I have a Joomla! blog that is using K2 to operate.

I'm struggling with the TAG page itself can't fetch some important data (The page that shows all the posts with the selected tag).

1) I want to display the name of the active tag (this is the file -> tag.php) but couldn't do that, i was trying to fetch it with:

<?php echo $tag->name; ?>

This didn't work.

2) It seems like author data is not available for the TAG page, couldn't echo the data of the author, not it's name: <?php echo $this->user->name; ?>

and not it's image: <img src="<?php echo $this->user->avatar; ?>">

Am I missing something or the tag.php just can't do those stuff?

1

There are 1 best solutions below

0
On

I'm not sure about your second question, but to display the tag name you could either create a menu item for each tag (long winded, I know), or you could put the following code in the tag.php file:

<h1>
    <?php echo $this->escape($this->params->get('page_title')); ?>
</h1>

Also be aware that the tag title will also include 'Tag:' before the tag name. This is controlled in your K2 language file. You can either rename it, or, if you just want to display the tag name, edit the language file and leave it blank.

I've written a full tutorial on how to do this: http://www.joomla-shark.com/joomla-tutorials/k2-tags-the-benefits-and-how-to-customise-the-k2-tag-page.html

Hope that helps