- Posts: 10
COMMUNITY FORUM
How set number of tags being displayed?
- Christian Nielsen
-
Topic Author
- Offline
- New Member
Less
More
10 years 8 months 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?
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 8 months 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.
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.
Please Log in or Create an account to join the conversation.
- Christian Nielsen
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 10
10 years 8 months 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; ?>
<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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 8 months ago #131737
by Krikor Boghossian
You can use this code as a starting point.
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.
Please Log in or Create an account to join the conversation.