Turns out there is a much easier way, still using the Page Class on each menu item. Found the answer here in a forum, and here in a Joomla Help Page.
Basically, you can use PHP to find the page that is being displayed, and put the class suffix anywhere in the document, i.e. in the
- put this code inside the head tag:
- <?php $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); $pageclass = ''; if (is_object($menu)) $pageclass = $menu->params->get('pageclass_sfx'); ?>
- Put this in the tag you want a class to. I.e. the body tag:
- <body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
You can also add another stylesheet to keep the css even more streamlined. Sorted! (oh, by the way, I havent tested any of this!!!!)
Well, after leaving it a while I came up with a problem. The specific page I want to change is a "featured-blog" menu item, so when I put the Page Class, I have to put a space to separate it from the word 'featured-blog'.
But alas, the pageclass picks this up! I had to get a php line in which trimmed the spaces from the pageclass:
$pageclass = trim($pageclass);
Well, after leaving it a while I came up with a problem. The specific page I want to change is a "featured-blog" menu item, so when I put the Page Class, I have to put a space to separate it from the word 'featured-blog'.
But alas, the pageclass picks this up! I had to get a php line in which trimmed the spaces from the pageclass:
$pageclass = trim($pageclass);
No comments:
Post a Comment