As of late I’ve been doing a lot of working on Joomla and creating a Joomla template for a school district that will be used district wide. It will not only be used on the districts website but it will also be used on the High School’s website, the Middle School’s website, and the Elementary School’s website. That’s a big thing for me because it means that the template has to actually be a template and not just a template that is that site specific, which I used to do a lot when creating Joomla templates. This has been a tremendous learning curve for me and has and will defiantly help me out when I do other website. Here are a couple coding tips for anyone who has use of them, but mainly they’ll be here for me to easily reference to and know where they are at.
This first one is to tell if the current page is from a certain Joomla component. The one in this example is JEvents, which is a really good calendar component for Joomla.
1 2 3 4 | <?php /*store true or false in a variable for ease of use*/$is_calendar = (JRequest::getCmd('option') == 'com_jevents'); ?> <?php /*see if this page is the events page*/ if ($is_calendar) : ?> <p>Do something in here if the page being displayed is of the com_jevents</p> <?php /*end the if statement */ endif; ?> |
The second one is to see if the current page is the front page, or the default that people go to when they come to your website.
1 2 3 4 | <?php /*store the menu in a variable for ease of use*/ $menu = JSite::getMenu(); ?> <?php /*see if the current page is the front page, if so then do something*/ if ($menu->getActive() == $menu->getDefault()) : ?> <?php /*if it's not, then do this instead*/ else : ?> <?php /*end our if statement saying if the page is the front page or not*/ endif; ?> |
Pretty nice and easy to do once you figure out how to do them, there’s so many different options out there that you can do. For example, the first one you can replace “com_jevents” with any other component and use it that way.
If you have any questions, feel free to ask!
Bradley Hilton







