Different layout per page with 1 template

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
MoonCore
New Member
New Member
Posts: 7
Joined: Wed Mar 25, 2009 2:20 pm

Different layout per page with 1 template

Post by MoonCore »

So I've got my site built up something like this.


 

 
   
      {content block="intro"}
etc...........

I've got 4 pages set up, 1.Home, 2.Portfolio, 3.About me, 4. Contact.

I want to remove the div "intro" from all pages except for home. In other words is it possible to delete and add divs depending on the page without using more than one template?
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Different layout per page with 1 template

Post by Wishbone »

When editing the content on your home page, click on Options and enter the following into the "Smarty data..." field

Code: Select all

{assign var="display_info" value="1"}
In your template, use:

Code: Select all

{if isset($display_info)}
<div id="intro">{content block="intro"}</div>
{/if}
Another option would be to capture the output of the content block, and insert logic to only display it if there is any content.. This way, you can use it on any page without having to set the variable
MoonCore
New Member
New Member
Posts: 7
Joined: Wed Mar 25, 2009 2:20 pm

Re: Different layout per page with 1 template

Post by MoonCore »

That is a great sollution thanks!

Would I be able to remove the editable area for the divs and content blocks that were removed from the page on the content->page area in the admin environment?
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Different layout per page with 1 template

Post by Wishbone »

I don't believe so..

I don't know why I didn't think of it before, but you can use a Global Content Block instead....

Code: Select all

{if isset($display_info)}
<div id="intro">{global_content name='info'}</div>
{/if}
Now you won't have any extra content blocks when editing any page... If you need to edit "Info", just edit the GCB.
MoonCore
New Member
New Member
Posts: 7
Joined: Wed Mar 25, 2009 2:20 pm

Re: Different layout per page with 1 template

Post by MoonCore »

Thanks a lot for helping! Works perfectly.  ;D
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Different layout per page with 1 template

Post by Wishbone »

Glad I could help! I do something similar on my site.

http://teamwishbone.com

Ignore the glaring graphical issues.  :( (Edit.. I fixed the glaring errors :)) Compare the home page vs. the others. I made an option to have different content in the black content section for each page, each with a different polaroid pic, but never got around to doing it.

Make sure you show us your site when you're done!
Last edited by Wishbone on Fri Jan 08, 2010 6:02 am, edited 1 time in total.
Post Reply

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