doupao1978 2012-08-15 02:13
浏览 38
已采纳

动态布局(每页的不同布局)

I'm trying to implement different layouts in Joomla. I'm using the Alias Name for setting different layouts for each page. I read an E-book about Joomla and there's no another method to create different layouts and or set it in the Backend Panel. I wanted to ask, is there be another method / way to set a different page from Backend Panel for each page ? I just want to make sure it's possible in Joomla 1.5.

My Previous Method

// Get Alias Page
function getCurrentAlias(){
   $menu= &JSite::getMenu();
   $active= $menu->getActive();
   return $active->alias;
}

After getting the Alias page name, I used a conditional statement to get different content for each page.

<-- Header Part -->
<-- Start Content Part -->
if( $pageName == "home" ){
   {{Content Home}}
}elseif( preg_match("#^(news).*$#", $pageName) ){
   {{Content News}}
}...etc
<-- End Content Part -->
<-- Footer Part -->
  • 写回答

2条回答 默认 最新

  • duanmianzhou5353 2012-08-16 16:56
    关注

    First, I wold recommend not using 1.5, it reaches end of life next month.

    however, if you are going to use 1.5, you are making it a lot harder than you need to. If you want to have significant structural differences from one page to another, you can install a template for each different structure you would like to use, then assign each template to the appropriate menu item. You would have to create menu items, even if they are in a hidden menu that is not displayed on the site.

    You can also control the structure of the page using CSS and collapsible module positions. Add this so you can set a page class suffix that adds an ID to the body tag of the page, making it easy to have page specific CSS:

    <?php
    $menu = &JSite::getMenu();
    $active = $menu->getActive();
    if (is_object( $active )) :
    $params = new JParameter( $active->params );
    $pageclass = $params->get( 'pageclass_sfx' );
    endif;
    ?>
    
    <body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
    

    Then for each of the module positions on the page, you can make them collapsible so they do not show up on the page if they are not being used:

    <?php if ($this->countModules('top')) : ?><div id="top"><jdoc:include type="modules" name="top" style="xhtml" /></div><?php endif; ?>
    

    So basically, if you don't put any modules in the "top" position it never gets put on the page. Using these 2 items in combination you can control exactly how each page looks with a single template.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式