- Posts: 8
COMMUNITY FORUM
How to limit item description characters?
- Yvonne
- Topic Author
- Offline
- New Member
Thanks!
Please Log in or Create an account to join the conversation.
- Yvonne
- Topic Author
- Offline
- New Member
- Posts: 8
Does K2 just support one category setting and not work with more than one categories? What I means is that I selected more than one categories content to display on my home page. In that case the introtext will display all the words on my home page even though I set the limitation parameter on each category.Yvonne wrote: Hi all, I am wondering how to limit the characters of K2 item description? Here is my situation: I created "Home" menu which will direct to K2 categories. So on my homepage is K2 categories view, but the items will display all the description characters and looks messy. I tried to change the parameters on K2 category setting. This works when click the category menu, but not work on homepage.
Thanks!
Can somebody help? Thanks!
Please Log in or Create an account to join the conversation.
- Daniel Hristov
- Offline
- New Member
- Posts: 14
In your category item template you can use the following code:
<?php if($this->item->params->get('catItemIntroText')): ?>
<?php
if($this->item->params->get('catItemIntroTextWordLimit') == ''){
$itemdesc = $this->item->introtext;
$itemdesclimit = '520';
if (!empty($itemdesc)) {
$thisitemdesc = strip_tags($itemdesc);
$thisitemdesc = substr($thisitemdesc, 0, $itemdesclimit);
$thisitemdesc = substr($thisitemdesc, 0, strrpos($thisitemdesc, ' ')).'...';
} else {}
} else {
$thisitemdesc = $this->item->introtext;
}
?>
<?php echo $thisitemdesc; ?>
Please Log in or Create an account to join the conversation.
- Yvonne
- Topic Author
- Offline
- New Member
- Posts: 8
Could you tell me more particular? Could you tell me which file I need to paste these code to?
Please Log in or Create an account to join the conversation.
- Daniel Hristov
- Offline
- New Member
- Posts: 14
Search for:
<?php if($this->item->params->get('catItemIntroText')): ?>
<!-- Item introtext -->
<div class="catItemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
and replace it with the code I gave before.
Please Log in or Create an account to join the conversation.
- jetlininja
- Offline
- New Member
- Posts: 6
Daniel Hristov wrote: If you want to create custom K2 template, you should copy the content of [ components/com_k2/templates ] (four files and a 'default' folder) to the 'html' folder in your template directory (base_dir/templates/your_temp_name/html/com_k2 - if you wish, you can give a different name for your new k2 template). The file which you have to edit to set the desired description is category_item.php
Search for:
<?php if($this->item->params->get('catItemIntroText')): ?>
<!-- Item introtext -->
<div class="catItemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
and replace it with the code I gave before.
It did not work.
After replacing the codes, my site becomes completely blank.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
- Posts: 15920
.I tried to change the parameters on K2 category setting. This works when click the category menu, but not work on homepage.
This setting only work when a menu item is pointing towards a single category and not multiple categories.
You can either manually specify an introtext for your items ( in my opinion this is the best option ) or,
you can select which tags to strip (globally) from the content tab on the component's configuration and use a simple PHP snippet like :
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.