Keyword

Add specific class to K2 items

  • David Muller
  • David Muller's Avatar Topic Author
  • Offline
  • New Member
More
11 years 8 months ago #109568 by David Muller
Add specific class to K2 items was created by David Muller
Hi, this may seem like a dumb question, but is it possible to add custom .css classes to K2 item so that they can be styled individually?

I've made a responsive css file which hides the article image when the screen is wide (a video is there instead) and when the page is resized or viewed on a mobile phone the image is visible again and the video hidden.

But, if I want to Categories in K2 they both inherit these styles. Adding a page class suffix in the Main Menu doesn't help either, as Firebug shows that this class is filtering down to the item view.

To hide the image I'm using:

#k2Container .itemImage {
display: none!important;
}

To hide the video I'm using:
.avVideo .avPlayerContainer {
display: none;
}

So if I add a page class suffix to the main menu like; _content I'd like to call that with:

#k2Container .itemImage_content {
display: none!important;
}

Thus separating out the two styles from the two categories. Is this possible?

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

  • David Muller
  • David Muller's Avatar Topic Author
  • Offline
  • New Member
More
11 years 8 months ago - 11 years 8 months ago #109569 by David Muller
Replied by David Muller on topic Re: Add specific class to K2 items
Actually, I think I may have solved this.

I created another custom template folder and altered line 207 of item.php from:

<span class="itemImage">

to:

<span class="itemImage_crew">

Calling that new template from the k2 Edit Category manager seems to have done the biz!

Is this the right solution or a monumentally ugly hack?

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


Powered by Kunena Forum