Page 1 of 1

Different layout per page with 1 template

Posted: Thu Jan 07, 2010 11:13 pm
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?

Re: Different layout per page with 1 template

Posted: Fri Jan 08, 2010 12:00 am
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

Re: Different layout per page with 1 template

Posted: Fri Jan 08, 2010 12:56 am
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?

Re: Different layout per page with 1 template

Posted: Fri Jan 08, 2010 1:09 am
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.

Re: Different layout per page with 1 template

Posted: Fri Jan 08, 2010 1:22 am
by MoonCore
Thanks a lot for helping! Works perfectly.  ;D

Re: Different layout per page with 1 template

Posted: Fri Jan 08, 2010 2:41 am
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!