- Posts: 9
COMMUNITY FORUM
specific css class by article tags
- tincup
- Topic Author
- Offline
- New Member
Less
More
10 years 2 months ago #130842
by tincup
specific css class by article tags was created by tincup
Hello,
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.
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
Less
More
- Posts: 15920
10 years 2 months ago #130843
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: specific css class by article tags
You can do it by overriding the category_item.php file.
The you have to echo all the tags in the top container.
Example:
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'); ?>">
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- tincup
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
10 years 2 months ago - 10 years 2 months ago #130844
by tincup
Replied by tincup on topic Re: specific css class by article tags
I modified category_item.php but I get this error:can you help me?
I would like to see changed the upper class by tag -> "ItemContainer"
<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
Less
More
- Posts: 15920
10 years 2 months ago #130845
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: specific css class by article tags
Can you turn error reporting off please?
This snippet contains the if/ endif statement for the tags.
You need to have set your tags to show in order to work.
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.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- tincup
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
10 years 2 months ago - 10 years 2 months ago #130846
by tincup
Replied by tincup on topic Re: specific css class by article tags
hi,
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
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
Less
More
- Posts: 15920
10 years 1 month ago #130847
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: specific css class by article tags
Are tags enabled for that category?
You need to set the tag settings to show in order for this to work.
You need to set the tag settings to show in order for this to work.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- tincup
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
10 years 1 month ago #130848
by tincup
Replied by tincup on topic Re: specific css class by article tags
I set a tag for each article and the tags result enabled in the settings tags. the css class, however, does not change.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 1 month ago #130849
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: specific css class by article tags
Are you sure you edited the correct category_item file,
This post will help you locate it,
nuevvo.com/blog/item/84-k2-inheritance-sub-templating
This post will help you locate it,
nuevvo.com/blog/item/84-k2-inheritance-sub-templating
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- tincup
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
10 years 1 month ago #130850
by tincup
Replied by tincup on topic Re: specific css class by article tags
I have only one file category_item.php and is located in ./components/com_k2/templates/default
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 1 month ago - 10 years 1 month ago #130851
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: specific css class by article tags
Then you should override it instead of editing it.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Then please send me a link to the issue.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Then please send me a link to the issue.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.