Keyword

Add item or cat ID, NAME or even TYPE to body or html class suffix

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
4 years 7 months ago - 4 years 7 months ago #175392 by Gorast
Hello,
I hope this post find you well and healthy :D

I need some heavy styling to my pages but I need to separate K2 items from category listing.
How can I add class or ID suffix to the body or html tags of the page?

Ideally I wold have class="item-ID cat-ID k2item (or k2cat, if its a listing)".

I managed to add this to the <article> adding "k2Item-<?php echo $this->item->id; ?>" but not working on the page.
How can I achieve this?

Thanks,
Gorast
Last edit: 4 years 7 months ago by Gorast.

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

More
4 years 7 months ago #175397 by JoomlaWorks
Can you add the class to the <body> tag of your template? Or are you using a template framework that constructs the output and makes it hard to edit that tag?

If you can edit it, then use this code: github.com/joomlaworks/Takai/blob/master/includes/helper.php#L162 (the are also references at the top of that file)

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

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
4 years 7 months ago - 4 years 7 months ago #175403 by Gorast
Hello,
it uses Gavick template. The line that gets the body code is in default.php:

$tpl_page_suffix = $page_suffix_output != '' ? ' class="'.$page_suffix_output.'" ' : '';

<body<?php echo $tpl_page_suffix; ?><?php if($this->browser->get("tablet") == true).....>
Last edit: 4 years 7 months ago by Gorast.

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

More
4 years 7 months ago #175420 by JoomlaWorks
Grab the code I mentioned and adapt it accordingly then.

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

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
4 years 7 months ago #175422 by Gorast
hey Fotis,
I got this code from the theme developer and work properly. It suits my needs:

<html class="<?php if(isJoomla4()) echo 'j4'; ?> <?php echo $option; ?> layout-<?php echo $layout; ?> view-<?php echo $view ?>" lang="<?php echo $this->APITPL->language; ?>" <?php echo $tpl_page_suffix; ?> >

The one thing they couldn't manage is to get the actual item ID.

Thanks,
Gorast

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

More
4 years 7 months ago #175432 by JoomlaWorks
<?php echo JRequest::getInt('id'); ?>

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

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
4 years 7 months ago #175434 by Gorast

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

More
4 years 7 months ago #175435 by JoomlaWorks
You're welcome.

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

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


Powered by Kunena Forum