【问题标题】:Joomla frontpage component template parameter switchJoomla首页组件模板参数切换
【发布时间】:2013-09-12 10:15:35
【问题描述】:

使用 Joomla 3.1 并创建模板。

我有一个模板参数开关来显示或隐藏首页'组件'。

我目前在我的 index.php 文件中使用以下内容:

<?php
$menu = & JSite::getMenu();
if($menu->getActive() !== $menu->getDefault()) : 
?>
<jdoc:include type="component" />
<?php endif; ?>

我想在上面添加一个&lt;?php if ($frontpageshow) : ?&gt; 语句,以便发生以下情况:

  1. 如果我的模板参数设置为“显示首页组件” - &lt;jdoc:include type="component" /&gt; 将显示在首页和所有页面上。

  2. 如果我的模板参数设置为“隐藏首页组件” - &lt;jdoc:include type="component" /&gt; 在首页不显示,但在所有其他页面显示页面。

有什么想法吗?

我的templateDetails.xml如下:

<field name="frontpageshow" type="radio" class="btn-group" default="1" label="TPL_FRONTPAGESHOW_LABEL" description="TPL_JOOSTRAP_DESC">
   <option value="1">JYES</option>
   <option value="0">JNO</option>
</field>

我有另一个文件声明我的变量,即

$frontpageshow = $this->params->get('frontpageshow');

【问题讨论】:

  • 你能添加你的模板 XML 吗?
  • templateDetails.xml 用于添加到上述帖子的“frontpageshow”字段。
  • 我还有另一个文件,其中包含我的变量,如下所示 $frontpageshow = $this->params->get('frontpageshow');但很高兴这个进入我的 index.php 文件的顶部

标签: php if-statement joomla joomla3.0


【解决方案1】:

尝试以下方法:

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();

if ($frontpageshow){ 
    // show on all pages
    ?><jdoc:include type="component" /><?php 
}
else {
    if ($menu->getActive() !== $menu->getDefault()) {
        // show on all pages but the default page
        ?><jdoc:include type="component" /><?php
    } 
}
?>

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-14
    • 2018-06-02
    • 1970-01-01
    • 2012-06-15
    • 2013-08-24
    • 1970-01-01
    • 1970-01-01
    • 2022-08-03
    相关资源
    最近更新 更多