Vincent Mross
I like to add a body class to all of my template installations because it makes styling individual pages very easy. Adding a page class to a menu item doesn't always do the trick, because it only affects the component area of the page. Here is how I do it in Joomla 4/5:
Add this to the head area:
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive();
$pageclass = '';
if (is_object($menu))
$pageclass = $menu->getParams()->get('pageclass_sfx');
?>
[b]And this to the body area:[/b]
[code]<body class="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
Anything without a page class will use a class of "default", anything with the page class defined will appear as the class entered into “Page Class” in the Menu Manager.
The problem I am having is that the Samba Spa template overrides the body class in mobile view, rendering it like this:
<body id="s5_body" class="s5_responsive_mobile_present">
I made a post in the Joomla forums about this issue here:
forum.joomla.org/viewtopic.php?f=808&t=1009296
In that thread, Pavel-ww mentions that
the problem with Body classes comes from this file "s5_responsive_mobile_bar-min.js" The logic of the script should be rewritten so that it does not replace the classes, but adds to the existing ones.
What I have tried with ReReplacer (I bought the pro version so that I could target only the home page by using conditions) is this:
Search:
class="s5_responsive_mobile_present"
Replace:
class="s5_responsive_mobile_present home homie"
I have tried with and without regular expressions, but no luck.
But apparently the file "s5_responsive_mobile_bar-min.js" overwrites whatever is outputted by ReReplacer. How can I get around this? Here is the website by the way:
feminapt.com/