Joomla 3根据toggler在同一位置显示不同的模块

时间:2015-07-16 14:24:24

标签: module joomla3.4

有我的问题:

我有一些切换部分。此部分应根据单击的触发器显示动态内容。所以,例如。通过点击“支持”,应该提供一些联系信息/下载支持工具,点击“搜索” - 搜索框等。

我的问题是,如果只有一个模块位置可以解决这个问题,或者每个触发器需要一个位置吗?

希望描述这个可理解的=)

感谢任何帮助。

由于

亚历

UPD: 我将尝试用代码解释:

模块位置

   if ($this->countModules('pos-1')) : 
        $module = JModuleHelper::getModules( 'pos-1' );
        foreach($modules as $m) : ?>
            <section class="mod_%echo $m->title%">
                <jdoc:include type="modules" name="pos-1" style="xhtml" />
            </section>
        endforeach;
    endif;

并触发

if ($this->countModules('pos-1')) : 
    $module = JModuleHelper::getModules( 'pos-1' ); 
    foreach($module as $m) :
        <a class="btn-collapse collapsed" role="button" data-toggle="collapse" data-parent="#accordion" 
        href="#echo $m->title;" aria-expanded="true" aria-controls=" echo $m->title;">
            <i class="fa fa-building-o"></i> <? echo $m->title; ?>
        </a>                        
    endforeach;
endif;

所以我在这个位置添加了两个CustomHTML模块。

结果

<section ... class="mod_title1">
    content mod_one
    content mod_two
</section>
<section ... class="mod_title2">
    content mod_one
    content mod_two
</section>

<a ... href="#mod_title1" ...>  mod_title1 </a>
<a ... href="#mod_title2" ...>  mod_title2 </a>

应该是

<section ... class="mod_title1">
    content mod_one
</section>
<section ... class="mod_title2">
    content mod_two
</section>

<a ... href="#mod_title1" ...>  mod_title1 </a>
<a ... href="#mod_title2" ...>  mod_title2 </a>

所以我认为这是不可能的,因为只有一个职位,而且很多人都应该解决这个问题。

如果我弄错了,请纠正我。

UPD2:我错了。这是可能的,但不仅仅是通过模板 - 还应该使用自己的功能扩展模块chrome tempalte以使其正确。

2 个答案:

答案 0 :(得分:1)

这可以做到。您必须在:

下为每个模块添加一个单独的类(分配给相同的模块位置)
Module Settings -> Advanced -> Module Class Suffix

因此,如果您添加了suff1suff2类,则可以使用以下方法切换它们:

jQuery(document).ready(function() {
  jQuery("div.suff1, div.suff2").on("click", function() {
    jQuery(this).parent().children().toggle();
  });
});
div {
  width: 180px;
  height: 100px;
  color: white;
}
div.suff1 {
  background: orange;
  display: none;
}
div.suff2 {
  background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div>
  <div class="suff1">Module 1</div>
  <div class="suff2">Module 2</div>
</div>

答案 1 :(得分:0)

不确定您的问题,但如果您的触发器是菜单条目,您可以告诉您的模块仅在选择了这些菜单条目时才会显示。
进入扩展程序 - &gt;模块管理器,选择所需的模块,然后在模块分配选项卡中 - &gt;模块分配仅在所选页面上选择&#34;&#34;并选择所需的菜单条目 您可以让模块处于相同的位置。仅当指定的菜单项处于活动状态时,您的模块才会显示在该位置 HTH