joomla 上的高级条件模块位置
我有一个盒子,里面包含三个模块位置。现在的目标是当一个模块位置单独加载时,它的宽度应该是盒子的100%;当两个模块位置加载时,每个模块的宽度应为50%;最后,当所有三个位置都加载时,每个位置应为 33%。 我怎样才能用最少的编码来设置这个条件? 我的代码现在是这样的:
<?php if ($this->countModules( 'user1 or user2 or user3' )) : ?>
<div style="width:860px; margin:10px auto;">
<?php if ($this->countModules( 'user3' )) : ?>
<div style="width:33%; float:left; min-height:100px;"><jdoc:include type="modules" name="user3" style="xhtml" /></div>
<?php endif; ?>
<?php if ($this->countModules( 'user2' )) : ?>
<div style="width:34%; float:left; min-height:100px;"><jdoc:include type="modules" name="user2" style="xhtml" /></div>
<?php endif; ?>
<?php if ($this->countModules( 'user1' )) : ?>
<div style="width:33%; float:left; min-height:100px;"><jdoc:include type="modules" name="user1" style="xhtml" /></div>
<?php endif; ?>
</div>
<?php endif; ?>
more explain:
我想定义每个特殊条件,但这样我不知道如何比较“三个”(或更多)位置。即我知道当我想“仅显示两个位置之一(而不是两个位置)”时,我应该使用这个:
<?php if ($this->countModules( 'user1 xor user2' )) : ?>>
但是如果我想同时将一个位置与其他两个位置进行比较;代码是什么?类似的东西:?
<?php if ($this->countModules( 'user1 xor user2 or user3' )) : ?>
在上面的代码中,我想仅显示user1或仅 user2或user3位置之一。这是真的吗?
谢谢
I have a box which contains three module positions inside.Now the target is when a module position loaded alone, its width should be 100% of the box; when two of the modules positions loaded, the width of each one should be 50%; and finally when all three positions loaded, apiece should be 33%.
How could I set this conditions with the least coding?
my code is now something like this:
<?php if ($this->countModules( 'user1 or user2 or user3' )) : ?>
<div style="width:860px; margin:10px auto;">
<?php if ($this->countModules( 'user3' )) : ?>
<div style="width:33%; float:left; min-height:100px;"><jdoc:include type="modules" name="user3" style="xhtml" /></div>
<?php endif; ?>
<?php if ($this->countModules( 'user2' )) : ?>
<div style="width:34%; float:left; min-height:100px;"><jdoc:include type="modules" name="user2" style="xhtml" /></div>
<?php endif; ?>
<?php if ($this->countModules( 'user1' )) : ?>
<div style="width:33%; float:left; min-height:100px;"><jdoc:include type="modules" name="user1" style="xhtml" /></div>
<?php endif; ?>
</div>
<?php endif; ?>
more explain:
I think to define every special condition but in this way I don't know how to compare "three" (or more) positions with each other. i.e I know when I want to ِ Display just one of two positions (and not both of them), I should use this:
<?php if ($this->countModules( 'user1 xor user2' )) : ?>>
But if I wanna compare one position with two other positions at the same time; What will be the code? somethings similar this: ?
<?php if ($this->countModules( 'user1 xor user2 or user3' )) : ?>
in above code I want to show just user1 or only one of user2 or user3 positions. Is it true?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它比这简单得多:暂时忘记 joomla-countModules-funkyness。然后您可以相当快地获取模块的数量:
将 coutModules-Return 转换为布尔值是
$this->countModules( 'user1' ) 的快捷方式? 1:0。
It's much simpler than that: for a second, forget about the joomla-countModules-funkyness. Then you can get the number of Modules rather quickly:
Converting the coutModules-Return to a boolean is a shortcut for
$this->countModules( 'user1' ) ? 1 : 0
.此外,这应该可以通过纯 HTML/CSS 实现。我记得如果你制作一个列大小为“100%”且宽度固定的表格,浏览器会自动缩放它以符合列数:
我怀疑这是否符合 HTML 标准,但......
Also, this should be possible with plain HTML/CSS. I recall that if you make a table with column size "100%" and fixed width, the browser scales it automatically to comply with the number of columns:
I doubt this is HTML-Standard-Compliant, though ...