Joomla 3根据切换器,在同一位置显示不同的模块 [英] Joomla 3 Show different modules on same position depending on toggler

查看:80
本文介绍了Joomla 3根据切换器,在同一位置显示不同的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有我的问题:

我有一些切换部分.此部分应显示动态内容,具体取决于单击的触发器.因此,例如.通过单击支持",应该提供一些联系信息/下载支持工具,并单击搜索"-搜索框等.

i have some toggle section. This section should show dynamical content depending on clicked trigger. So eg. by clicking "support", there should be some contact information/download support tool provided, on clicking "search" - search box etc.

我的问题是,是否可以仅使用一个模块位置来解决该问题,或者每个触发器需要一个位置?

My question is if it is possible to solve this with only one Module position or its need one position for each trigger?

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

Hope to describe this understandable =)

感谢您的帮助.

谢谢

亚历克斯

UPD: 我将尝试使用代码进行解释:

UPD: I will try to explain with code:

模块位置:

   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模块.

So i have added two CustomHTML modules to this position.

结果:

<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>

所以我认为仅靠一个位置是不可能的,应该解决许多问题.

So i think this is not possible with only one position adn should be solved with many.

如果我写错了,请纠正我.

Please correct me if i have it wrong.

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

UPD2: I was wrong. This is possible but not only via Template - also module chrome tempalte should be extended with own functin to render it right.

推荐答案

可以这样做.您必须在以下位置为每个模块添加一个单独的类(分配给相同的模块位置):

This could be done. You have to add a separate class to each module (assigned to the same module position) under:

Module Settings -> Advanced -> Module Class Suffix

因此,如果您添加了suff1suff2类,则可以使用:

So if you have added suff1 and suff2 classes you could toggle them using:

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>

这篇关于Joomla 3根据切换器,在同一位置显示不同的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆