Keyword

Show tags in Layout & view options for Tag listing

  • Federica
  • Federica's Avatar Topic Author
  • Offline
  • New Member
More
12 years 4 months ago #59299 by Federica
Hi, in the parameters of k2 2.5, if I go in the in "Layout & view options for user (author) pages" I have the possibility to show or hide the "Item tags".

I need to do the same with the "Layout & view options for Tag listing", I want to show the item tags!

Please, could someone help me??

Thanks

Please Log in or Create an account to join the conversation.

  • Federica
  • Federica's Avatar Topic Author
  • Offline
  • New Member
More
12 years 4 months ago #59300 by Federica
I found a solution! :)

I've add this code in tag.php and it works.

<?php
$tags = K2ModelItem::getItemTags($item->id);
for ($i=0; $i<sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags=$tags;
?>
<?php if(count($item->tags)): ?>
<!-- Item tags -->
<div class="catItemTagsBlock">
<span><?php echo JText::_("Tagged under"); ?></span>
<ul class="catItemTags">
<?php foreach ($item->tags as $tag): ?>
<li><a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a></li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #59301 by Matt
Thank you so much. That was exactly what I needed. One can only hope that this and many other options shall be officially integrated to K2. K2 has so much potential but it's far from perfect. Not to mention the support forum turned into a football advertising forum.

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #180316 by texier
Hi, with php8 this code displays now the following error :

Non-static method K2ModelItem::getItemTags() cannot be called statically

Does anyone have an idea to resolve this error? Thanks...

Please Log in or Create an account to join the conversation.

More
1 year 6 months ago #180317 by texier
If it could help someone, this new code works :

<?php
    $K2ModelItem = new K2ModelItem();
    $tags = $K2ModelItem->getItemTags($item->id);
for ($i=0; $i<sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags=$tags;
?>
<?php if(count($item->tags)): ?>
<!-- Item tags -->
<div class="catItemTagsBlock">
<span><?php echo JText::_("Tagged under"); ?></span>
<ul class="catItemTags">
<?php foreach ($item->tags as $tag): ?>
<li><a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a></li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum