Templates 模板宽度可调?

Templates 模板宽度可调?,templates,joomla,width,Templates,Joomla,Width,好, 我相信这个问题以前已经得到了回答,我也相信这个链接可以帮助我 我对语法或php编码不是很熟悉,所以我很难理解我要做的事情 我正在构建一个joomla 2.5模板,我正在使用countmodules来隐藏“div”或整个位置,因为那里没有发布模块。我的问题是,假设在我的100%宽度的主列中,有时我想在主内容框中内容的右侧显示一个模块,宽度仅为整个列宽度的25%。好的,这很有效 然而,我想把内容向左浮动,这个25%宽度的模块我们称之为“right1”,它向右浮动,所以我需要给我的主要内容一个7

好,

我相信这个问题以前已经得到了回答,我也相信这个链接可以帮助我

我对语法或php编码不是很熟悉,所以我很难理解我要做的事情

我正在构建一个joomla 2.5模板,我正在使用countmodules来隐藏“div”或整个位置,因为那里没有发布模块。我的问题是,假设在我的100%宽度的主列中,有时我想在主内容框中内容的右侧显示一个模块,宽度仅为整个列宽度的25%。好的,这很有效

然而,我想把内容向左浮动,这个25%宽度的模块我们称之为“right1”,它向右浮动,所以我需要给我的主要内容一个75%左右的宽度,使所有内容都能很好地浮动并正确显示,它做到了!我的问题是,如果“right1”不存在,我不知道如何使我的主要内容具有100%的宽度。如果我在“right1”中没有显示任何模块,因此它不显示,我将如何更改我的主要内容的css以调整到100%,而不是缩小到75%,以弥补缺少的right1位置

我可能真的很蠢,有一个简单的解决办法就在我面前,我记不得了。提前谢谢

-编辑-

它是这样的

<div id="contentcontainer">
<jdoc:include type="message" /><jdoc:include type="component" />
<?php if ($this->countModules( 'right1' )) : ?>
<div id="right1"><jdoc:include type="modules" name="right1" style="xhtml" /></div>
<div class="clearfix"></div><?php endif; ?><?php if ($this->countModules('right2')): ?>
<div id="right2"><jdoc:include type="modules" name="right2" style="xhtml" /></div>
<div class="clearfix"></div>
<?php endif; ?>

</div></div></div>
我把内容用来浮动的标签放在左边;我试着对主要内容使用“最小宽度”,最小宽度似乎不起作用。所以什么是解决方案,希望我不必像建议的那样求助于jQuery。这些信息足够吗


-编辑-

您可以使用一些简单的PHP和内联样式来完成。我不是PHP方面的专家,所以这可能没有它可能是优雅的,但我相信有人会纠正它

   <div id="contentcontainer">

    <?php 
    //column calculation
    $columns == 0;
    if($this->countModules( 'right1' )) {$columns++;}
    if($this->countModules( 'right2' )) {$columns++;}
    $centercolumnwidth = 100 - (25 * $columns);
    ?>

    <jdoc:include type="message" />

    <div id="maincolumn" style="width:<?php echo $centercolumnwidth ?>%">
        <jdoc:include type="component" />
    </div><!--/maincolumn-->

    <?php if ($this->countModules( 'right1' )) : ?>
    <div id="right1">
        <jdoc:include type="modules" name="right1" style="xhtml" />
    </div><!--/right1-->
    <div class="clearfix"></div>
    <?php endif; ?>

    <?php if ($this->countModules('right2')): ?>
    <div id="right2">
        <jdoc:include type="modules" name="right2" style="xhtml" />
    </div><!--/right2-->
    <div class="clearfix"></div>
    <?php endif; ?>

</div><!--/contentcontainer-->


您能否在中显示您正在使用的代码
countmodules
?这样我们可以提出一些建议
   <div id="contentcontainer">

    <?php 
    //column calculation
    $columns == 0;
    if($this->countModules( 'right1' )) {$columns++;}
    if($this->countModules( 'right2' )) {$columns++;}
    $centercolumnwidth = 100 - (25 * $columns);
    ?>

    <jdoc:include type="message" />

    <div id="maincolumn" style="width:<?php echo $centercolumnwidth ?>%">
        <jdoc:include type="component" />
    </div><!--/maincolumn-->

    <?php if ($this->countModules( 'right1' )) : ?>
    <div id="right1">
        <jdoc:include type="modules" name="right1" style="xhtml" />
    </div><!--/right1-->
    <div class="clearfix"></div>
    <?php endif; ?>

    <?php if ($this->countModules('right2')): ?>
    <div id="right2">
        <jdoc:include type="modules" name="right2" style="xhtml" />
    </div><!--/right2-->
    <div class="clearfix"></div>
    <?php endif; ?>

</div><!--/contentcontainer-->