Keyword

Adding custom class to K2 articles in view by tag

  • Lech Zbigniew Dutkiewicz
  • Lech Zbigniew Dutkiewicz's Avatar Topic Author
  • Offline
  • New Member
More
11 years 5 months ago - 11 years 5 months ago #112560 by Lech Zbigniew Dutkiewicz
Adding custom class to K2 articles in view by tag was created by Lech Zbigniew Dutkiewicz
I'm new here and it's my very first question. I'm also new in web design and not-so-good in English so I ask for forbearance :)

In one of my first projects I use Joomla 3.0 and K2 to create a wall-like portfolio with articles about handbags. Since each of them belongs to more than 1 category, I used tagging and tag-view instead of default category-view. It's quite important for my project to differ featured articles and articles with one specified tag to display different from others - I'll use css for that. But I have no idea how to add this information into div's class. In view by category I used
<?php echo ($this->item->featured) ? ' catItemIsFeatured' : ''; if ($this->item->params->get('catItemTags')): foreach ($this->item->tags as $tag): echo ' ' . $tag -> name; endforeach; endif;?>

in item's container div. My understanding of this is rather small and I don't know why it doesn't work for view by tag.

Thank all of You for any answer!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 5 months ago #112561 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Adding custom class to K2 articles in view by tag
Hello Lech,

First of all best of luck with designing :)

Firstly K2 only supports one category per item so I guess you are using an extension for this.
I think you might want to rethink your approach and use the category views since it is more flexible.

Finally inside tag you will need $item-> instead of $this-> item.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Lech Zbigniew Dutkiewicz
  • Lech Zbigniew Dutkiewicz's Avatar Topic Author
  • Offline
  • New Member
More
11 years 5 months ago #112562 by Lech Zbigniew Dutkiewicz
Replied by Lech Zbigniew Dutkiewicz on topic Re: Adding custom class to K2 articles in view by tag
Hi,

Thanks for Your advice. Instead of using multiple categories I decided to try tags. That's why my site shows items listed by tag instead by category. For my current project it seems nessessary to use multiple categories for articles and I didn't know any other way to do that than by tags.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum