简体   繁体   English

Joomla-根据文章更改模板位置

[英]Joomla - Change template position based on the Article

I need to change some positions on the Joomla template based on the article loaded. 我需要根据加载的文章更改Joomla模板上的某些位置。

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 ... 好的,这有点棘手,您可以获取当前的页面名称(菜单名称),然后在模板源中为每个“页面”创建if语句,下面举一个例子……假设您有一个联系人页面,并且如果用户在联系人页面上,您想向该页面添加位置...

<?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 ... 因此,您必须锻炼整个模板并为每个页面做好准备,这是一个简单的示例,您可以自行扩展...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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