Content and Columns

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
Ziggywigged
Power Poster
Power Poster
Posts: 424
Joined: Sat Feb 02, 2008 12:42 am

Content and Columns

Post by Ziggywigged »

Hello,

Using 1.5.2 and this nifty little snippet to only display a right sidebar column if content is entered:

Code: Select all

{content block='sidebar' assign='sidebar_var' oneline='true'}
{if !empty($sidebar_var)}
<div class="rightCol">{$sidebar_var}</div>
{/if}
rightCol is set to float right in my css and the main content div set to float left. What I'd like to do is have the content div span my wrapper area width (900px) unless of course there is a side column which would take up 250px, leaving the content div at around 550px. I've tried setting width:auto and setting no width at all but it always spans the whole width of my wrapper and the rightCol gets pushed underneath. Hope that makes sense. Any suggestions?

Thanks.
Take a penny, leave a penny.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Content and Columns

Post by calguy1000 »

maybe something like this:

Code: Select all

{content block='sidebar' assign='sidebar_var' oneline='true'}
{if !empty($sidebar_var)}
  {assign var='mainwidth' value='550'}
  <div class="rightCol">{$sidebar_var}</div>
{else}
  {assign var='mainwidth' value='900'}
{/if}
<div class="main_area" style="width: {$mainwidth}">
{content}
</div>
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Ziggywigged
Power Poster
Power Poster
Posts: 424
Joined: Sat Feb 02, 2008 12:42 am

Re: Content and Columns

Post by Ziggywigged »

Thanks Calguy, worked like a charm after minor addition of 'px' after {$mainwidth}.

E.g.:
{content block='sidebar' assign='sidebar_var' oneline='true'}
{if !empty($sidebar_var)}
  {assign var='mainwidth' value='550'}
  {$sidebar_var}
{else}
  {assign var='mainwidth' value='900'}
{/if}

{content}


Many thanks.
Take a penny, leave a penny.
Post Reply

Return to “Layout and Design (CSS & HTML)”