如何在Joomla 3.0中修复此模块样式问题

时间:2013-04-11 12:21:13

标签: templates joomla module styles joomla-extensions

我有一个这样的CSS类:

.divTourCategorySummaryBoxLeft, .divTourCategorySummaryBoxRight {
    width: 98%;
    min-height: 350px;
    border: 1px dashed #9CAAC6;
    padding: 2px;
    margin-bottom:3px;
    background: #DEE7EF;
    color: #000063;
    line-height: 1.4em;
    display:block;
    overflow:auto;

}

然后我在index.php中包含这样的模块:

<div class="divTourCategorySummaryBoxRight">
    <jdoc:include type="modules" name="modTourCategorySummaryRight" />
</div>

这看起来很完美。但是,我需要在同一页面上有多个这样的模块。因此,当我添加nother模块时,它出现在同一个div中。这不是我想要的方式。对于每个模块,必须有一个单独的div。模块数量未知。

所以我尝试了这个:

<jdoc:include type="modules" name="modTourCategorySummaryLeft" style="divTourCategorySummaryBoxLeft" />

但造型在这里失败了。如何让它为每个模块显示一组新的div?

请告知。

这是我自己的模板,我从头开始构建joomla文档。我对此很陌生。 谢谢!

1 个答案:

答案 0 :(得分:2)

您需要创建一个新的module chrome。在模板html文件夹中,创建名为modules.php的文件。

在里面,制作一个这样的功能

defined('_JEXEC') or die;

function modChrome_customstyle($module, &$params, &$attribs)
{
    if (!empty ($module->content)) : ?>
            <div class="divTourCategorySummaryBoxRight">
                 <div class="moduletable">
                      <?php if ($module->showtitle != 0) : ?>
                           <h3><?php echo $module->title; ?></h3>
                      <?php endif; ?>
                      <?php echo $module->content; ?>
                 </div>
            </div>
    <?php endif;
}

这样您就可以创建自定义模块输出。

然后,在您的模板文件中,包含如下模块:

     <jdoc:include type="modules" name="modTourCategorySummaryLeft" style="customstyle" />

添加style="customstyle"后,您的新功能将用于渲染模块。默认样式为xhtml,您可以在modules.php文件的templates/system/html文件夹中找到它的代码