How to switch between 1 and 3 column layout

When using a fixed width design, you always run into the problem of not having enough space to load a forum or gallery.

Now the typical work around would be to design two templates. One to use for the site (2 or 3 columns) and one to use for the forum / gallery or any other component that requires more space.

This method works, but is more of a hassle than it is worth, as it requires twice as much work and is not as effective as the method i am highlighting below.

Using a switch statement, you can conditionally load your template with 1, 2 or even 3 columns. The way it works, is when the template is loaded, it checks to see whether the components you have set are being called. If so, it will load the first part of the template that is outlined below. If not, it will use the second bit – which is set to default.

<table>
<tr>
<td><?php mosPathWay(); ?></td>
</tr>
<!-- IF FORUM OR GALLERY, THEN LOAD 1 COLUMN -->
<?php switch ($option) {
case 'com_smf':
case 'com_gallery':
?>
<tr>
<td><?php mosMainBody(); ?></td>
</tr>
<!-- ELSE LOAD THE TWO COLUMN LAYOUT -->
<?php
break;
default:
?>
<tr>
<td><?php mosMainBody(); ?></td>
<td><?php mosLoadModules ( 'right' ); ?></td>
</tr>
<?php ;
break;
}   ?>
</table>

About the author

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>