- Posts: 9
COMMUNITY FORUM
specific css class by article tags
- tincup
-
Topic Author
- Offline
- New Member
I would like to know if it is possible to change the css class for specific article in blog layout according to tags.
(if an article I know you can do it for different categories by assigning specific template, but I need to do this for tags.
I guess it's possible to do it through php code but I'm not good at this. Can you help? Sorry for my bad English.
Thanks in advance.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
The you have to echo all the tags in the top container.
Example:
<div class="catItemView <?php foreach ($this->item->tags as $tag) { echo $tag->name; } ?> group<?php echo ucfirst($this->item->itemGroup); ?><?php echo ($this->item->featured) ? ' catItemIsFeatured' : ''; ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?>">
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
<div class="catItemView <br />
<b>Notice</b>: Undefined property: stdClass::$tags in <b>/opt/lampp/htdocs/fab/components/com_k2/templates/default/category_item.php</b> on line <b>19</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/opt/lampp/htdocs/fab/components/com_k2/templates/default/category_item.php</b> on line <b>19</b><br />
I would like to see changed the upper class by tag -> "ItemContainer"
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
This snippet contains the if/ endif statement for the tags.
<div class="catItemView group<?php echo ucfirst($this->item->itemGroup); ?> <?php if($this->item->params->get('catItemTags') && count($this->item->tags)){ foreach ($this->item->tags as $tag) { echo $tag->name; }} ?> <?php echo ($this->item->featured) ? ' catItemIsFeatured' : ''; ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?>">
You need to have set your tags to show in order to work.
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
I can not make it work. I put tags on each article and replaced the code in category_item.php but the css class is always "catItemView." You can take a look at the file?
Thanks
Attachment not found
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You need to set the tag settings to show in order for this to work.
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
This post will help you locate it,
nuevvo.com/blog/item/84-k2-inheritance-sub-templating
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Then please send me a link to the issue.
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
But the css class is always "catItemView".
this is the link of the site is still under construction: alternativo.fablabsassari.org
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- tincup
-
Topic Author
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.