0

I have a template that needs to include a section in the header on some pages. I could use a module for this. But in only shows up on some pages, and that needs to be determined at article level. So "article a" would have the extra content and "article b" would not. I don't like the idea of a hidden menu because there could potentially be thousands of these articles and it requires an extra step for the authors. It seems like the best solution might be an alternate layout, which could be selected while creating or editing the article. So the question is, how can I turn the module on and off based on the alternate layout? Can I get the value of the alternate layout and do something with that (call a file with the same name for instance)?

EDIT: At this point I am simply trying to determine if an alternate layout is in use and if it is, what it is named. I am trying to access this in a template override (templates/mytemplate/index.php)

4

2 に答える 2

0

すべてのページのモジュールを調整 (位置を調整) し、テンプレートでこの位置をテンプレートから非表示にするためのルールを追加できます。たとえば、次のようになります。

<?php if($articleID == 1){?><jdoc:include type="modules" name="menu" /><?php}?>
于 2013-02-28T21:59:25.350 に答える
0

これが私がたどり着いた場所です。

別のレイアウトを取得するには、次のようにします。

    $article =& JTable::getInstance("content");
    $article->load(JRequest::getInt("id"));
    $attribs=new JParameter($article->attribs);
    $layout=$attribs->get("article_layout");

これで、次のように、このレイアウトに対して実行したい特別なことを含むファイルを参照できます。

        if($layout != ''){
            $layoutname=str_replace($this->template . ':', '', $layout);
            $path=JPATH_ROOT .'/templates/'. $this->template .'/html/com_content/article/' . $layoutname . '_include.php';      
            require_once $path;
        }

追加のセクションを必要とするレイアウトには、他の代替レイアウト ファイルを含むフォルダーに、alternate_layout_name_include.php という名前の別のファイルが必要です。

私は Joomla や php が苦手なので、ヒント、コードの変更、入力はいつでも歓迎します。

于 2013-03-01T23:28:40.587 に答える