Page 1 of 1

FAQ: How do I collapse an empty position in a template?

Posted: Fri Sep 15, 2006 2:07 am
by leolam
Very often the question is asked on how to collapse a position in any template. Note collapse here means "not show" if no modules are published to these columns.............

Here is a method on how to do this as an example with the tremendous popular rhuk_solarflare template:

open ../templates/rhuk_solarflare_ii/index.php and find and replace this:

Code: Select all

      <div id="left_outer">
                      <div id="left_inner">
                      <?php mosLoadModules ( 'left', -2 ); ?>
                      </div>
                  </div>
                  <div id="content_outer">
with this :

Code: Select all

      <?php
                    if ( !(mosCountModules( 'left' )) ) {
                  ?>
                  <div id="content_outer2">
                  <?
                    }
                    else {
                    ?>
                  <div id="left_outer">
                      <div id="left_inner">
                      <?php mosLoadModules ( 'left', -2 ); ?>
                      </div>
                  </div>
                  <div id="content_outer">
                  <?
                  }
?>
and save the file.

then open ../templates/rhuk_solarflare_ii/css/template_css.css file add this: and add

Code: Select all

#content_outer2 {
    padding: 0px;
    margin-top: 0px;
    margin-left: 0px;
    /** border: 1px solid #cccccc; **/
    float: left;
    width: 800px;
}
save and your left column now will collapse when you don't publish anything to it!

This method you can multiply to any template if you try to follow the logic of the code!

cheers  ;)
Leo