这是我创建的这个基本模块系统,用于在joomla模板中创建一个6列网格系统是的我已经成功地为每个网格创建了不同的类,即如果只有4个模块从joomla的后端启用了dc类-modules4会自动启用等等,但是我需要帮助调用一个类来保存一个模块但是现在当我调用CSS类时它保存所有模块并用dc-module4包装它以便我可以设置该类的样式在CSS这里是代码,这将有助于你理解它。
<?php
function Top(){
$modules = array();
$modules["top1"] = '<jdoc:include type="modules" name="top1" style="xhtml" />';
$modules["top2"] = '<jdoc:include type="modules" name="top2" style="xhtml" />';
$modules["top3"] = '<jdoc:include type="modules" name="top3" style="xhtml" />';
$modules["top4"] = '<jdoc:include type="modules" name="top4" style="xhtml" />';
$modules["top5"] = '<jdoc:include type="modules" name="top5" style="xhtml" />';
$modules["top6"] = '<jdoc:include type="modules" name="top6" style="xhtml" />';
foreach($modules as $module => $name){
echo '<div class="dc-modules">'.$name.'</div>';
}
}
if($this->countModules('top1')){
$mod[0] = 'mod1';
}
if($this->countModules('top2')){
$mod[1] = 'mod2';
}
if($this->countModules('top3')){
$mod[2] = 'mod3';
}
if($this->countModules('top4')){
$mod[3] = 'mod4';
}
if($this->countModules('top5')){
$mod[4] = 'mod5';
}
if($this->countModules('top6')){
$mod[5] = 'mod6';
}
$result = count($mod);
if($result == 6){
echo '<div class="dc-modules6">';
echo Top();
echo '</div>';
}
if($result == 5){
echo '<div class="dc-modules5">';
echo Top();
echo '</div>';
}
if($result == 4){
echo '<div class="dc-modules4">';
echo Top();
echo '</div>';
}
if($result == 3){
echo '<div class="dc-modules3">';
echo Top();
echo '</div>';
}
if($result == 2){
echo '<div class="dc-modules2">';
echo Top();
echo '</div>';
}
if($result == 1){
echo '<div class="dc-modules1">';
echo Top();
echo '</div>';
}
?>
答案 0 :(得分:0)
<?php
if($this->countModules('top1')){
$modules["top1"] = '<jdoc:include type="modules" name="top1" style="xhtml" />';
}
if($this->countModules('top2')){
$modules["top2"] = '<jdoc:include type="modules" name="top2" style="xhtml" />';
}
if($this->countModules('top3')){
$modules["top3"] = '<jdoc:include type="modules" name="top3" style="xhtml" />';
}
if($this->countModules('top4')){
$modules["top4"] = '<jdoc:include type="modules" name="top4" style="xhtml" />';
}
if($this->countModules('top5')){
$modules["top5"] = '<jdoc:include type="modules" name="top5" style="xhtml" />';
}
if($this->countModules('top6')){
$modules["top6"] = '<jdoc:include type="modules" name="top6" style="xhtml" />';
}
if(isset($modules)){
$result = count($modules);
foreach($modules as $module => $name){
if($result == 6){
echo '<div class="dc-modules6">';
echo $name;
echo '</div>';
}
if($result == 5){
echo '<div class="dc-modules5">';
echo $name;
echo '</div>';
}
if($result == 4){
echo '<div class="dc-modules4">';
echo $name;
echo '</div>';
}
if($result == 3){
echo '<div class="dc-modules3">';
echo $name;
echo '</div>';
}
if($result == 2){
echo '<div class="dc-modules2">';
echo $name;
echo '</div>';
}
if($result == 1){
echo '<div class="dc-modules1">';
echo $name;
echo '</div>';
}
}
}
?>