- Posts: 5
COMMUNITY FORUM
Show tags in Layout & view options for Tag listing
- Federica
- Topic Author
- Offline
- New Member
Less
More
12 years 4 months ago #59299
by Federica
Show tags in Layout & view options for Tag listing was created 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
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
12 years 4 months ago #59300
by Federica
Replied by Federica on topic Re: Show tags in Layout & view options for Tag listing
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; ?>
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.
- Matt
- Offline
- Senior Member
Less
More
- Posts: 56
12 years 3 months ago #59301
by Matt
Replied by Matt on topic Re: Show tags in Layout & view options for Tag listing
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.
- texier
- Offline
- New Member
Less
More
- Posts: 3
1 year 6 months ago #180316
by texier
Replied by texier on topic Re: Show tags in Layout & view options for Tag listing
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...
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.
- texier
- Offline
- New Member
Less
More
- Posts: 3
1 year 6 months ago #180317
by texier
Replied by texier on topic Re: Show tags in Layout & view options for Tag listing
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; ?>
<?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.