To start we need to pull in the information of which menus are being used on the page. Place this code in the head of your template:
jimport('joomla.application.menu');
$menus = JSite::getMenu();
$m = $menus->getActive();
This checks for the active menus on the page and sets it into the variable $m so we can manipulate it. Next, you need to look at the menutype in the administrator Menu Manager (under Type). This is what we will use to determine which school is being viewed. I want to take this information and set a new variable named $school:
if($m->menutype == 'district-information') { $school = 'district-info'; }
if($m->menutype == 'cityname-elementary-school') { $school = 'cityname-elementary'; }
if($m->menutype == 'cityname-middle-school') { $school = 'cityname-middle'; }
if($m->menutype == 'cityname-high-school') { $school = 'cityname-high'; }
The first thing I did was echo the variable $school into an ID on the body tag.
body id="< ?php echo $school; ?>"
This allows me to style the CSS uniquely according to the school being viewed which gives you a lot of style control. To change the logo I can just call it by the school.
#cityname-high .logo {background: url(../images/logo-highschool.jpg);}
Another thing I did was load a unique module position according to the school so I could publish modules in all pages the menu shows up on. I did this by doing the following:
if($school == 'district-info') {
echo '
};
if($school == 'cityname-elementary') {
echo '
};
if($school == 'cityname-middle') {
echo '
};
if($school == 'cityname-high') {
echo '
};
As you can see this can give you the ability to do things you may not have been able to do before in Joomla!. I know it saved me from a major headache!
You can find original post here : http://www.corephp.com/blog/controlling-joomla-templates-depending-on-the-menu-you-use/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.