Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Joomla 侧栏模块位置内每个模块的不同框_Joomla_Joomla2.5 - Fatal编程技术网

Joomla 侧栏模块位置内每个模块的不同框

Joomla 侧栏模块位置内每个模块的不同框,joomla,joomla2.5,Joomla,Joomla2.5,我制作了一个Joomla 2.5模板。你可以在这个网站上查看:www.ranfar.com 看看侧边栏的代码。到现在为止,我已经有了类似的东西: <div id="sidebar"> <!-- Here starts the first widget --> <h3>Widget title</h3> <ul>......... <!-- Module content --> ..........&l

我制作了一个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>
    
    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;
    }
    
    
    模块名称
    

      通过这种方式,我可以为模块框设置类的样式。 如何实现这样一个模板?我必须在哪里添加它?这是我在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; ?>
      

      在Joomla中,它们被称为模块(而不是小部件)。在XML文件中,需要添加模块位置,如下所示:

      <positions>
          <position>login</position>
          <position>search</position>
          <position>sidebar1</position>       
          <position>sidebar2</position>
          <position>etc...</position>
      </positions>
      
      
      登录
      搜索
      侧边栏1
      侧边栏2
      等
      
      在模板中,然后使用上面的代码添加每个模块位置:

      <jdoc:include type="modules" name="sidebar1" style="xhtml" />
      
      
      
      无论在何处,Joomla都会在其位置显示模块(下一段)。关于“风格”的快速说明-你可以做一个s

      然后,在模块管理器中,创建一个新模块并选择您希望它出现的位置。

      我找到了一个解决方案

      我必须打开文件
      /templates/THEME/html/modules.php
      ,其中
      THEME
      是我的主题的名称。有如下功能:

      <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>
      
      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\u侧栏($module,&$params,&$attribs)
      {
      如果(!empty($module->content)):?>
      
      抱歉,我称它们为widget,但我知道它们称为modules。我已经在该位置添加了module position和module。我的问题是用一个特定的类将每个模块封装在一个div中,该类对于在该位置添加的所有模块都必须相同。我应该为它们创建自定义样式吗?当然,或者您可以使用如果你想让模块做一些不同的事情,模板覆盖是非常有用的:尽管已经过时,但大多数仍然是相关的,解释得更好:你应该选择这个作为正确答案。这是控制模块chrome的标准方法。