简体   繁体   中英

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...).

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 ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM