1

我有一个 joomla 网站,我只想在主页上有模块内容。我找到了其他解决方案,但它们似乎适用于 joomla 3.0 和 Gantry 框架。有没有人对此有更新的解决方案?

这是我需要为主页隐藏的代码:

    <?php /** Begin Main Body * */ ?>
        <?php echo $gantry->displayMainbody('mainbody', 'sidebar', 'standard', 'standard', 'standard', 'standard', 'standard'); ?>
    <?php /** End Main Body * */ ?>

我想知道是否有一种方法可以使用条件来仅针对 hompage 隐藏此代码,例如这篇文章:

joomla 1.5 帖子的相同想法

4

2 回答 2

1

将此代码添加到模板文件的开头 html 部分之前(但在 php 标签内):

$app = JFactory::getApplication();
$menu = $app->getMenu();
$isFrontPage = $menu->getActive() == $menu->getDefault();

然后你可以用这个替换行:

<?php if (!$isFrontPage) echo $gantry->displayMainbody('mainbody', 'sidebar', 'standard', 'standard', 'standard', 'standard', 'standard'); ?>
于 2013-08-06T17:15:40.803 回答
0

一种可能的解决方案是添加一个名为 disable_content 的新位置并检查其中是否有活动模块。如果是这样,您不显示内容。

要添加位置,请在 templateDetails.xml 中编辑<positions>

<positions>
    ..
    <position>disable_content</position>

现在要检查您是否有活动模块,只需使用:

$disable_content = (bool) $this->countModules('disable_content');

所以现在你可以使用

<?php if (!$disable_content) : ?>
    <?php echo $gantry->displayMainbody('mainbody', 'sidebar', 'standard', 'standard', 'standard', 'standard', 'standard'); ?>
<?php endif; ?>
于 2015-03-11T00:20:59.193 回答