Thursday, March 6, 2008

3 Columns : Son of Moto : Two Right Sidebars

Article Series: 3 Column Step by Step Guides

Here are the steps to convert a default 2 column Son of Moto template in to a 3 column template with two sidebars on the right hand side of the main post area.

(If you really want to understand what's happening here, read the article series Three Column Templates Explained.)

1) Add a new CSS id selector for the 2nd sidebar wrapper.

  • Go to Layout -> Edit HTML
  • Locate the #sidebar section (Do a Find using your browser)
  • Copy that full section and paste below the existing sidebar section (it doesn't have to below) and rename it to #sidebar-two
  • Change the float: $endSide to float:$startSide of the #sidebar section (See the code snippet below)

#sidebar {
width: 226px;
float: $startSide;
color: $sidebarTextColor;
word-wrap: break-word; /* fix for ... in IE */
overflow: hidden; /* fix for long ... */
}

#sidebar-two {
width: 226px;
float: $endSide;
color: $sidebarTextColor;
word-wrap: break-word; /* fix for ... IE */
overflow: hidden; /* fix for ... float */
}


2) Introduce a new div element, as a child of the content-wrapper, to be the placeholder for the 2nd sidebar
  • Locate the <div id='sidebar-wrapper'> element.
  • Copy the code shown in red, below that section (this has to be below)

<div id='sidebar-wrapper'>
<b:section class='sidebar' id='sidebar' preferred='yes'>
</b:section>
</div>

<div id='sidebar-wrapper-two'>
<b:section class='sidebar' id='sidebar-two' preferred='yes'>
</b:section>
</div>

<!-- spacer for skins that want sidebar and main to be the same height-->
<div class='clear'> </div>


3) Expand the width of the parent wrappers to accommodate the new sidebar
  • Locate the CSS section called #outer-wrapper
  • Change its width property to 918 pixels

#outer-wrapper {
margin: 0 auto;
border: 0;
width: 918px;
...
}


4) Do necessary adjustments to margins, padding etc
  • Locate the #main section
  • Insert a right margin of 14 pixels.

#main {
width: 400px;
margin-$endSide:14px;

float: $startSide;
...
}


5) Modify and expand the background images as necessary.
  • Add a template variable to define the image host location as explained here. (This step will open up in a separate window. Return to the next bullet point after that)
  • Locate the body section.
  • Replace the URL of the background image to the one shown in red below.

body {
...
background: #692 url($imageHost/sonofmoto_outerwrap_w.gif) top center repeat-y;
...
}

Note: Step 6 is only needed if your Layout Editor does not show the newly added sidebar. There was an issue where Firefox browser didn't show a 3 column template fully in the edit mode. But Blogger reports that the issue has been fixed and this step was not required when I tested these steps.

6) Modify the CSS rules for the wire frame layouts editor.
  • Locate the section that starts with "/** Page structure tweaks for layout editor wireframe */"
  • Replace that entire section with the following code.

/** Page structure tweaks for layout editor wireframe */

body#layout #outer-wrapper {
padding-top: 0;
width:720px;
}
body#layout #header,
body#layout #content-wrapper,
body#layout #footer {
padding: 0;
width:720px;
}

body#layout #main {
width:400px;
}

body#layout #sidebar,
body#layout #sidebar-two {
width:150px;
}

]]></b:skin>


Save the template. Switch to Page Elements view and enjoy your 3 column template! (Let me know if you come across any problems)

Note: You are free to use the image provided by me. But if you change your template according to this tutorial and use that image, please do a post in your blog linking to this article.