In Development
Joomla! Template Tutorial - Collapsible Columns
Joomla! Template Tutorial - Collapsible Columns
You've got a great template with a left and right column, but you've noticed that when you have no modules in left and/or right, the article area (component) doesn't stretch to fill the width of the page.
You want your modules to collapse when they are not used, so the page naturally fills more elegantly.
Let's take a look at a template generated by Artisteer, for example.
The index.php looks like this:

In the yellow highlight area, you can see where the contentLayout div is created. This is the div that holds everything on the Sheet under the navbar/header and above the footer area.
If you were to look in your style.css, you would find a definition for .contentLayout .content. Depending on whether you generated both left and right or just left or right, you will find that .contentLayout .content width definition is equal to the width of the sheet - width of sidebar1 (if included) - width of sidebar2 (if included).
You'll want to add just a little bit of CSS now to define a .content1side and a .content0side. Just copy .contentLayout .content and paste it twice and chang its name to .contentLayout .content1side (the first one) and .contentLayout .content0side (the second one). Make the width of .content1side = to the width from .content + the width of .sidebar1. Make the width of content0side = the width from .content + the width of .sidebar1 and .sidebar2.
Ok - back to our index.php now.

We are going to add a few conditional statements here to tell the index.php which content we are using based on what (if any) of the left and right modules are used. If we use left and right, we want our page to go in .content. If we use left or right but not both left and right, we want our page to go in .content1side. If there is no left or right in use, we want our page to go in .content0side.
Here's how we do that. Just add a little bit to the index.php to replace from <div class="sidebar1"> to <div class="content"> with this:

Now, we will want to do the same thing down at the bottom of index.php to only include sidebar2 if right is in use - just like we did for sidebar1.

Now, your left and right columns will collapse when not in use.
Your css will look something like this:
/* begin LayoutCell */
.contentLayout .content {
position: relative;
margin: 0;
padding: 0;
border: 0;
float: left;
overflow: hidden;
width: 534px;
}
/* end LayoutCell */
/* begin LayoutCell */
.contentLayout .content1side {
position: relative;
margin: 0;
padding: 0;
border: 0;
float: left;
overflow: hidden;
width: 714px;
}
.contentLayout .content0side {
position: relative;
margin: 0;
padding: 0;
border: 0;
float: left;
overflow: hidden;
width: 894px;
}
/* end LayoutCell */
/* begin LayoutCell */
.contentLayout .sidebar1 {
position: relative;
margin: 0;
padding: 0;
border: 0;
float: left;
overflow: hidden;
width: 176px;
}
.contentLayout .sidebar2 {
position: relative;
margin: 0;
padding: 0;
border: 0;
float: left;
overflow: hidden;
width: 176px;
}
/* end LayoutCell */
Trackback(0)
TrackBack URI for this entryComments (14)
Subscribe to this comment's feedi don't undertand
can u help me please
this is how my file looks now
div class="contentlayout">
/* Only build sidebar1 if left is assigned any modules*/
...
Parse error: syntax error, unexpected '{'
The error you see indicates that there is an error in your php syntax - an opening brace without a closing brace.
Probably, you opened an if statement and neglected to close it.
I've also just noticed bbcode's aren't working properly in these comments. Now, I've got something amusing to look into this afternoon
...
was happy to found this code !!!!!
....but have same problem " unexpected '{' ".
Have copied original the modifications above 1to1 in my idex.php.
But it don't work.
Could you please check ??? Or the best: Is it possible to make the modified index.php for dowload ?? That would be great !!!!
...
Somewhere, you probably left out the line that closes the if statement with a }.
If you download this month's free template, you'll get an index.php file with this technique.
Parse error: syntax error, unexpected T_ENDIF
"Parse error: syntax error, unexpected T_ENDIF in /home/uneedmyt/public_html/templates/uneedmytimemsauce/index.php on line 75
I'm also new to php so im clueless to whats happening. Could you help me out with this plzz.
...
One thing you might want to do is go to artisteer website and download the newest version. It includes collapsible columns in the latest version.
Typos
But there are two nasty typos that make you crazy, so I tell you:
In the code that replaces from to make sure you close the if-question with a second ")" after ...left').
In the code taking care of sidebar2 you need to add ">" after /div
Thanx Christian!!
But Christian is right those two typos almost drove me nuts! I would recommend that you update them for the sanity of Artisteer users ;-)
and
Womens Supra Society
http://www.benivolent.com/joom...pment.html
Write comment

Last Updated (Sunday, 22 March 2009 16:15)







