• Login
  • Register
  • Account
  • About 'corePHP'
  • Portfolio
  • SiteMap

Joomla! Development, Professional Joomla! Templates, Components, Extensions and Plugins — 'corePHP

Professional website development and design services

  • Home
  • Joomla! Products
    • Components
      • Community ACL
      • Droomla
      • jomCalendar
      • jomLike
      • JPhoto
      • Mortgage Calculators
      • WordPress
    • Plugins
      • Amazon Pack
      • Automated CSS3 Generator
      • Chimp Your Joomla!
      • JAutosearch
      • jomCDN
      • jomDefender
      • VirtueMart Age Restriction Plugin
    • jomSocial Add-ons
      • jomGive
    • Dreamweaver
      • Template Basics
    • JPhoto Add-ons
      • JPhoto Slideshow
    • cACL Add-ons
      • DOCman Plugin
    • CB Plugins
      • DOCman Downloads
    • Modules
      • YouTube Module
  • Templates
    • Joomla Themes
    • WordPress Themes
    • Drupal Themes
  • Services
    • Joomla! Services
      • Joomla! Install and Upgrading Services
      • Joomla! Website Design/Maintenance
      • Joomla! Custom Development
      • Joomla! Component Development
    • Template Services
      • Joomla! Template Conversion
      • Joomla! Template Design
      • PSD Template Design
    • Print Service
      • Print Design
  • Resources
    • Affiliate Club
    • Search Engine Submissions
    • 'corePHP' Partners
  • Blog
  • Support
    • Submit Ticket
    • Community Forums
  • Contact Us

Search the Blog

  • Categories

    • 'corePHP'
    • 'corePHP' Products
    • Accessibility
    • Dreamweaver
    • Expos
    • Flash
    • Graphics
    • Javascript
    • Joomla
    • Marketing
    • Mobile
    • Operating System
    • Other
    • PHP
    • Print
    • Public News Articles
    • Recommended Software
    • security
    • Templates
    • Tools
    • Uncategorized
    • XHTML+CSS
  • Pages

    • Chicago ’09
    • Denver Expo / Fun
  • Archives

    • February 2012
    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • May 2008
    • February 2008
    • January 2008
    • September 2007
    • April 2007
    • February 2007
    • December 2006
    • September 2006
    • August 2006
    • July 2006
    • June 2006
    • May 2006

Tag Cloud

'corePHP'  Android  app  Battle Creek  bugs  Christmas  CMS Expo  community  Community Acl  css  denver  discount  fix  holidays  html  ie  ie6  iOS  jomCDN  jomMobile  jomsocial  Joomla  Joomla! 1.5  Joomla! 1.6  Joomla Chicago  joomla extensions  joomla products  JPhoto  mobile  new products  new release  PHP  plugins  products  sale  security  small business  snippets  Steven Pignataro  success  template  tips  WordPress  WordPress MU  youtube

'corePHP' Blog


Keep up to date on what's happening at 'corePHP'

« WordPress for Joomla! Training now available in Joomlashack University
Control HTML without javascript »

Controlling Joomla! templates depending on menu you use

We have been working on building a multi-school Joomla! website and there have been many hurdles to overcome since Joomla! isn’t a multi-site CMS. After searching for anything that’s common across each school, I realized the menu for each school could be used as a common denominator. If I could set a variable depending on which menu is loaded on the page then I can do just about anything I want, such as change the logo, set a unique CSS class, etc. After meeting with our developers we figured out how to do this and I’ll share it with all of you in case you ever need to do the same.

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 '<jdoc :include type="modules" name="district_module" style="raw" />';
};
if($school == 'cityname-elementary') {
    echo '<jdoc :include type="modules" name="elementary_module" style="raw" />';
};
if($school == 'cityname-middle') {
    echo '<jdoc :include type="modules" name="middle_module" style="raw" />';
};
if($school == 'cityname-high') {
    echo '<jdoc :include type="modules" name="high_module" style="raw" />';
};

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!

Share this:
  • Digg
  • del.icio.us
  • Twitter
  • StumbleUpon
  • email
  • Facebook
  • Fark
  • LinkedIn
  • Technorati
  • Google Bookmarks
  • Reddit

Tags: css, Joomla, PHP, snippets, template, tips

This entry was posted on Thursday, August 26th, 2010 at 3:42 pm by Jonathan and is filed under Joomla, PHP, Templates, XHTML+CSS. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Controlling Joomla! templates depending on menu you use”

  1. Bill says:
    August 26, 2010 at 4:51 pm

    This is great, especially the module logic. What if:

    An article appears on the middle school “site”. On the front page (the district home) there is an article with a link to the middle school article. When someone clicks on the link, will the article appear styled like the middle school “site” or like the district (main) site?

    Or would you be forced to add an Itemid=xx to the link?

Leave a Reply

Click here to cancel reply.

User Information

Message


'corePHP' Blog is proudly powered by WordPress. Joomla! extensions by 'corePHP'
Entries (RSS) and Comments (RSS).

  • We have been working on building a multi-school Joomla! website and there have been many hurdles to overcome since Joomla! isn't a multi-site CMS. After searching for anything that's common across each school, I realized the menu for each school could be used as a common denominator. If I could set a variable depending on which menu is loaded on th

'corePHP' at a Glance

  • About 'corePHP'
  • Portfolio
  • SiteMap

Joomla! Products

  • Joomla! Components
  • Joomla! Modules
  • Joomla! Plugins
  • Dreamweaver Snippets

Services

  • Joomla! Install and Upgrading Services
  • Joomla! Website Design/Maintenance
  • Joomla! Custom Development
  • Joomla! Component Development
  • Joomla! Template Conversion
  • Joomla! Template Design
  • PSD Template Design
  • Print Design

Resources

  • Search Engine Submissions
  • 'corePHP' Partners
  • Blog

Contact

  • Contact Us
  • Support Desk
  • Forums

Policy Statement

  • Terms of Service
  • Refund Policy
  • Cancel Subscription

Contact Us

(269) 979-5582
62 East Michigan Ave.
Suite 202
Battle Creek, MI 49017

Join Our Mailing List

Affiliate Club
Become an affiliate!

©2011 'corePHP' All Rights Reserved – Designed by 'corePHP'

  • Twitter
  • Plurk
  • Digg It
  • Facebook
  • LinkedIN
  • RSS