- Posts: 46
COMMUNITY FORUM
K2 tag subtemplate not working as expected
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
4 years 2 months ago #176902
by Andrea
K2 tag subtemplate not working as expected was created by Andrea
Hi, i've just noticed that for some reason the item titles get displayed above the item image in the tag view:
verticalife.it/it/blog/tag/piemonte
While all i want to do is having the items look just like on the main blog page:
verticalife.it/it/blog
So i went to public_html/templates/mytemplate/html/com_k2/templates/myblogtemplate and edited tag.php which not surprisingly had the item title blog ABOVE the item image. I then invered it, just like below:
However this didn't solve anything. I'm really confused lol, looking forward to your reply!
Have a nice day
verticalife.it/it/blog/tag/piemonte
While all i want to do is having the items look just like on the main blog page:
verticalife.it/it/blog
So i went to public_html/templates/mytemplate/html/com_k2/templates/myblogtemplate and edited tag.php which not surprisingly had the item title blog ABOVE the item image. I then invered it, just like below:
Warning: Spoiler!
<!-- Start K2 Item Layout -->
<div class="tagItemView">
<?php if($item->params->get('tagItemImage',1) && !empty($item->imageGeneric)): ?>
<!-- Item Image -->
<div class="tagItemImageBlock">
<span class="tagItemImage">
<a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $item->params->get('itemImageGeneric'); ?>px; height:auto;" />
</a>
</span>
</div>
<div class="clr"></div>
<?php endif; ?>
<div class="tagItemHeader">
<?php if($item->params->get('tagItemTitle',1)): ?>
<!-- Item title -->
<h2 class="tagItemTitle">
<?php if ($item->params->get('tagItemTitleLinked',1)): ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else: ?>
<?php echo $item->title; ?>
<?php endif; ?>
</h2>
<?php endif; ?>
<div class="clr"></div>
<?php if($item->params->get('tagItemDateCreated',1)): ?>
<!-- Date created -->
<span class="tagItemDateCreated">
<?php echo JHTML::_('date', $item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<?php endif; ?>
</div>
<div class="tagItemBody">
<?php if($item->params->get('tagItemIntroText',1)): ?>
<!-- Item introtext -->
<div class="tagItemIntroText">
<?php echo $item->introtext; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<div class="clr"></div>
<?php if($item->params->get('tagItemExtraFields',0) && count($item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="tagItemExtraFields">
<h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4>
<ul>
<?php foreach ($item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<?php if($extraField->type == 'header'): ?>
<h4 class="tagItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
<?php else: ?>
<span class="tagItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
<span class="tagItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($item->params->get('tagItemCategory')): ?>
<!-- Item category name -->
<div class="tagItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<a href="<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
</div>
<?php endif; ?>
<?php if ($item->params->get('tagItemReadMore')): ?>
<!-- Item "read more..." link -->
<div class="tagItemReadMore">
<a class="k2ReadMore" href="<?php echo $item->link; ?>">
<?php echo JText::_('K2_READ_MORE_BLOG'); ?>
</a>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<!-- End K2 Item Layout -->
However this didn't solve anything. I'm really confused lol, looking forward to your reply!
Have a nice day
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 2 months ago #176908
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic K2 tag subtemplate not working as expected
You need to edit /templates/mytemplate/html/com_k2/default/tag.php. Also move the files from /templates/mytemplate/html/com_k2/templates/myblogtemplate to /templates/mytemplate/html/com_k2/myblogtemplate. The additional "templates" folder inside com_k2 is no longer needed.
Why change default/tag.php? Because this is the template file loaded for tags that are not linked to a menu item and as such cannot have a different sub-template assigned to them. If the file does not exist, copy if from K2's source template files.
More on overriding K2 here: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates
Why change default/tag.php? Because this is the template file loaded for tags that are not linked to a menu item and as such cannot have a different sub-template assigned to them. If the file does not exist, copy if from K2's source template files.
More on overriding K2 here: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
4 years 2 months ago #176909
by Andrea
Replied by Andrea on topic K2 tag subtemplate not working as expected
Hi Fotis, i've got no "default" folder in this path /templates/mytemplate/html/com_k2/
Shall i create it?
Shall i create it?
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
4 years 2 months ago #176910
by Andrea
Replied by Andrea on topic K2 tag subtemplate not working as expected
Ok so i've created the default folder and edited the tag.php for it to display the image above the header, and that went fine. However it has messed up with other things, including the pagination, which i didn't alter (i just edited the code between the <!-- Start K2 Tag Layout --> / <!-- End K2 Tag Layout --> comments).
Please see the attached screenshots: any idea on what i should do?
Thanks again
Please see the attached screenshots: any idea on what i should do?
Thanks again
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
4 years 2 months ago #176911
by Andrea
Replied by Andrea on topic K2 tag subtemplate not working as expected
Nevermind i figured it out, couldn't find the "delete reply" option so thanks, i'll post here in the event i get other related issues!
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
4 years 2 months ago #176913
by Andrea
Replied by Andrea on topic K2 tag subtemplate not working as expected
Hi, i got nearly everything i wanted to do, i just have another question: is it possible to have all the tags of a given article displayed in the tag view? Please see attached screenshots: the first one is an item in the blog main category, the second is an item in the filter for tag page.
Links: verticalife.it/it/blog // verticalife.it/it/blog/tag/news
Thanks again for everything!
Links: verticalife.it/it/blog // verticalife.it/it/blog/tag/news
Thanks again for everything!
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 2 months ago #176916
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic K2 tag subtemplate not working as expected
Try placing this block where you want the tags to show up for each item:
Let me know if it works.
<?php if(isset($item->tags) && count($item->tags)): ?>
<!-- Item tags -->
<div class="tagItemTagsBlock">
<span><?php echo JText::_('K2_TAGGED_UNDER'); ?></span>
<ul class="tagItemTags">
<?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; ?>
Let me know if it works.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Andrea
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
4 years 2 months ago #176922
by Andrea
Replied by Andrea on topic K2 tag subtemplate not working as expected
Hi Fotis, thanks again for your assistance! I indeed managed to make tags appear thanks to your kind advice.
Just one more small thing: when i did so, the readmore below kind of got upwards, check both previous links to see the difference -- on the main blog page the readmore is standing at the very bottom of the container, on the tag view pages it has a gap. Any idea how i can fix it?
Just one more small thing: when i did so, the readmore below kind of got upwards, check both previous links to see the difference -- on the main blog page the readmore is standing at the very bottom of the container, on the tag view pages it has a gap. Any idea how i can fix it?
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 2 months ago #176927
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic K2 tag subtemplate not working as expected
Looks OK now on your site so I guess it was some CSS or order-of-HTML issue.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.