Keyword

Add class to image based on tag

More
11 years 4 months ago #114357 by Ari
Add class to image based on tag was created by Ari
Hi,
Is it possible to get the tags in the template even if "$this->item->params->get('catItemTags')" returns 0?

I want to add a class to the image on my front page in category_item.php. But "$this->item->tags returns nothing if I have tags disabled in the category. I want to be able to get the tags in the template code but dont want to list the tags in the usual manner.

How do I do this?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 months ago #114358 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add class to image based on tag
Hello Ari,

You can use a different K2 Template for your front page and remove the tags loops. That way even if you enable the tags the output will never render.

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

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

More
11 years 4 months ago #114359 by Ari
Replied by Ari on topic Re: Add class to image based on tag
That's what I have done now. It works. I just feel its a little hacky. Its not me that are going to use this so it would be best if I could access the tags without needing to enable it in the settings.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 months ago #114360 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Add class to image based on tag
Not really hacky.

There is another way though I have not tried it but it seems logical.

You can try with count($this->item->tags). You can check if the count is greater than zero

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

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

More
11 years 3 months ago #114361 by Ari
Replied by Ari on topic Re: Add class to image based on tag
$this->item->tags is empty when $this->item->params->get('catItemTags') is 0.

Thanks for trying :)

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


Powered by Kunena Forum