Shaolin
Shaolin

Reputation: 2551

Joomla - Change template position based on the Article

I need to change some positions on the Joomla template based on the article loaded.

Ex: I need to use different set of positions for a home page and different set of positions for inner pages. There are some common positions as well (Menu, Header, Footer,etc...).

Upvotes: 0

Views: 627

Answers (1)

HamZa
HamZa

Reputation: 14931

Okay this is a bit tricky, you can get the current page name (menu name) and then make if statements for each "page" you made in the template source, i'll give an example ... Let's say you have a contact page and you want to add a position to it if the user is on the contact page ...

<?php 
    $currentpage = JSite::getMenu()->getActive()->name ;

    // in joomla 2.5
     $currentpage = JSite::getMenu()->getActive()->title; 

    if($currentpage == "Contact"){
        echo '<jdoc:include type="modules" name="Contact" />';
    }
?>

And so you have to workout your whole template and anticipate for each page, this was a simple example and it's up to you to expand it ...

Upvotes: 1

Related Questions