2012-09-04 72 views
0

我制作了一个Joomla 2.5模板。你可以看看这个网站:www.ranfar.com。每个模块在侧边栏模块内的不同位置

查看边栏的代码。到现在为止,我已经类似的东西:

<div id="sidebar"> 
    <!-- Here starts the first widget --> 
    <h3>Widget title</h3> 
    <ul>......... <!-- Module content --> ..........</ul> 
    <!-- Here starts the second module --> 
    <p>.... <!-- Second module content --> .........</p> 
</div> 

正如你所看到的,我没有为每个插件一个单独的盒子。我想有以下内容:

<div id="sidebar"> 
    <!-- Here starts the first module --> 
    <div class="sidebar-module-box"> 
     <h3>Module title</h3> 
     <ul>......... <!-- Module content --> ..........</ul> 
    </div> 
    <!-- Here starts the second module --> 
    <div class="sidebar-module-box"> 
     <p>.... <!-- Second module content --> .........</p> 
    </div> 
</div> 

以这种方式,我可以为模块框的类风格。 我如何实现这样的模板?我必须在哪里添加它?这是我在index.php中生成侧边栏的代码:

<?php if($this->countModules('ranfar-rightsidebar')) : ?> 
    <div id="right-sidebar" class="float-right"> 
     <jdoc:include type="modules" name="ranfar-rightsidebar" style="sidebar" /> 
    </div> 
<?php endif; ?> 

回答

2

我已经找到了解决办法。

我不得不打开文件/templates/THEME/html/modules.php,其中THEME是我的主题的名称。还有像以下功能:

function modChrome_sidebar($module, &$params, &$attribs) 
{ 
    if (!empty ($module->content)) : ?> 
     <?php if ($module->showtitle) : ?> 
      <h3><?php echo $module->title; ?></h3> 
     <?php endif; ?> 
     <?php echo $module->content; ?> 
    <?php endif; 
} 

我不得不改变如下:

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

现在每个模块封闭带班“模块中的”一个div内。

+0

你应该选择这个作为正确的答案。这是控制模块镶边的标准方法。 –

0

在Joomla中,它们被称为模块(而不是窗口小部件)。在XML文件中,你需要添加模块位置,像这样:

<positions> 
    <position>login</position> 
    <position>search</position> 
    <position>sidebar1</position>  
    <position>sidebar2</position> 
    <position>etc...</position> 
</positions> 

在您的模板,然后使用该代码添加的每个模块位置,你有以上:

<jdoc:include type="modules" name="sidebar1" style="xhtml" /> 

无论你有把Joomla会将模块显示在其位置(下一段)。关于“风格”的快速说明 - 您可以制作一个custom one or use one of the ones Joomla has already depending on your markup need

然后,在模块管理,使一个新的模块,然后选择您希望它出现的位置。

+0

对不起,我称它们为小部件,但我知道它们被称为模块。我已经在该位置添加了模块位置和模块。我的问题是关于将每个模块放在一个div中,并且一个特定的类必须与该位置上添加的所有模块相同。我应该为他们创建一个自定义样式吗? – Zagorax

+0

当然,或者你可以使用模板覆盖的模块,如果你想让它做不同的事情 - 他们真的很有用,玩:http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core和虽然过时主要仍然相关和更好地解释:http://docs.joomla.org/Understanding_Output_Overrides – Gisto

相关问题