Keyword

How set number of tags being displayed?

  • Christian Nielsen
  • Christian Nielsen's Avatar Topic Author
  • Offline
  • New Member
More
10 years 3 weeks ago #131734 by Christian Nielsen
How set number of tags being displayed? was created by Christian Nielsen
Hi,

Just wonder if it's possible to set the number of tags to be displayed inside an item.

I want to be able to use as many tags that i want to, but only to show the first tag in the front end. Is this possible? Is this something i can do in the code?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 3 weeks ago #131735 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How set number of tags being displayed?
You can do this directly in your template.

You need to override your template.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

You have to exit the loop after the first tag has been echoed.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Christian Nielsen
  • Christian Nielsen's Avatar Topic Author
  • Offline
  • New Member
More
10 years 3 weeks ago #131736 by Christian Nielsen
Replied by Christian Nielsen on topic Re: How set number of tags being displayed?
Im sorry, but I'm not understand, i know what file to edit, but where and how do i and it before it loops?

<div class="itemLinks">
<?php if($this->item->params->get('itemTags') && count($this->item->tags)): ?>
<!-- Item tags -->
<div class="itemTagsBlock">
<span><?php echo JText::_(''); ?></</span>
<ul class="itemTags">
<?php foreach ($this->item->tags as $tag): ?>
<a href="<?php echo $tag->link; ?>"><h2><?php echo $tag->name; ?></h2></a>
<?php endforeach; ?>

</ul>
<div class="clr"></div>
</div>
<?php endif; ?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 3 weeks ago #131737 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How set number of tags being displayed?
<?php foreach ($this->item->tags as $key=>$tag): ?>
<?php  if($key == 0): ?>
//tag code goes here
<?php else: 
break;
 endif; ?>
<?php endforeach; ?>

You can use this code as a starting point.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum