- Posts: 26
COMMUNITY FORUM
Back to category link
- Novalee
-
Topic Author
- Offline
- Junior Member
I would like to add a "back to category {categoryname}" link above my item titles. Does anybody know how this works?
I tried to add some code to the item.php of my template of K2, but I don't see anything.
I addes this:
Before this:<!-- Item category to go back to category overview -->
<div class="itemCategory">
<span><?php echo JText::_('Back to category: '); ?></span>
<a href="<?php echo $this->item->category->link; ?>"><?php echo $this->item->category->name; ?></a>
test
</div>
<?php if(!empty($this->item->fulltext)): ?>
<?php if($this->item->params->get('itemIntroText')): ?>
<!-- Item introtext -->
<div class="itemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
Thanks in advance for your help!
Please Log in or Create an account to join the conversation.
- Aaron
-
- Offline
- Premium Member
Try this:
Original Code:
Aaron :)
Please Log in or Create an account to join the conversation.
- Novalee
-
Topic Author
- Offline
- Junior Member
- Posts: 26
thank you very much for your answer!
I tried this in the component/k2/templates/ all templates i have/item.php folder and also in the
/templates/mytemplate/html/k2/templates/all templates i have/item.php
I changed the original code to this:
<?php if($this->item->params->get('itemCategory')): ?>
<!-- Item category name -->
<div class="itemCategory">
<span><?php echo 'Back to category: '; ?></span>
<a href="<?php echo $this->item->category->link; ?>"><?php echo $this->item->category->name; ?></a>
</div>
<?php endif; ?>
but the change is not seen :(
I cleaned the cache and everything, but still the old text remains :((
Please Log in or Create an account to join the conversation.
- Aaron
-
- Offline
- Premium Member
1. Make sure your category is using the template you changed
2. Make sure you are on the ITEM page. (Sorry to sound so basic) - Click on the item to see only that item on the page to ensure you are on the item.php
Hope this helps.
Aaron :)
Please Log in or Create an account to join the conversation.
- Novalee
-
Topic Author
- Offline
- Junior Member
- Posts: 26
okay I succesfully changed the standard "Published in " category text to "Back to " category.
The last thing is that I would like to have this text directly after the item title, before the introtext starts, but can't get it to work there...
I tried to add it here:
<?php if($this->item->params->get('itemAuthor')): ?>
<!-- Item Author -->
<span class="itemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(empty($this->item->created_by_alias)): ?>
<a href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
<!-- Plugins: AfterDisplayTitle -->
<?php echo $this->item->event->AfterDisplayTitle; ?>
<?php if($this->item->params->get('itemCategory')): ?>
<!-- Item category name -->
<div class="itemCategory">
<span><?php echo 'Back to category: '; ?></span>
<a href="<?php echo $this->item->category->link; ?>"><?php echo $this->item->category->name; ?></a>
</div>
<?php endif; ?>
<!-- K2 Plugins: K2AfterDisplayTitle -->
<?php echo $this->item->event->K2AfterDisplayTitle; ?>
<?php if(
$this->item->params->get('itemFontResizer') ||
$this->item->params->get('itemPrintButton') ||
$this->item->params->get('itemEmailButton') ||
Where should I exactly place it?
Thank you so much for your help!
Please Log in or Create an account to join the conversation.