[SOLVED] Creating many templates from one?

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
Charmie
Forum Members
Forum Members
Posts: 80
Joined: Tue Mar 03, 2009 3:32 pm

[SOLVED] Creating many templates from one?

Post by Charmie »

Hi All,

Not sure if this has been answered.

Basically I have a page template which has 5 components which make up the design:
1 - Left hand navigation
2 - Left news block
3 - Content block wide
4 - Content block
5 - Right hand navigation

The header and footer are the same on every page.

Is there a way I can call different elements that make the page, depending on the page alias, instead of having to create serveral different templates to cover the variations.

So on my template I would have some code like this:
{If page_alias == 'club, training, courses'}
     xxxxx
     xxxx
     xxxx
{elseif page_alis == 'news, gallery, blog'}
     
     

     etc......
{/if}

I thought I could use Smarty Tags, but am not quite sure how they work?

Also the News components for each page would need to display a different category, does anyone know how this would be possible to do?

Thanks
Charmie
Last edited by Charmie on Thu May 07, 2009 12:02 pm, edited 1 time in total.
laits
Forum Members
Forum Members
Posts: 50
Joined: Thu Sep 04, 2008 11:21 pm

Re: Creating many templates from one?

Post by laits »

Hi There,

Personally I think you may be getting into the overthinking trap, use the functions available within the cms instead of trying to do something smarter (or messier as the case ends up) than whats actually a really good cms.

Sounds like you need 2 templates - a left and a right

for the rest use the content block function

For instance I have a different gallery on every page in one of my cmsms's. I call the gallery in the only template i have, by using
{content block="Gallery"}

Whatever you call the content block i.e. {content block="PageNews"} will appear in edit page menu of the cms - no further programming needed - place the block in the template and it shall appear.

You can then put the variables in there - on a per page basis, when entering the content (or {content} in your template)

In my different gallery on every page example, i have

{cms_module module='album' albums='1'} on page 1
{cms_module module='album' albums='2'} on page 2 etc etc

Place the module in the content block rather than tying it down to the template.

You can put anything in a content block, and have as many as you like, and they all magically appear! Just put each one in a div and style with css.

Hope that helps - from someone who has overcomplicated cms far too many times until one day i got a bang on the head!

Rich
Last edited by laits on Wed May 06, 2009 9:36 am, edited 1 time in total.
Charmie
Forum Members
Forum Members
Posts: 80
Joined: Tue Mar 03, 2009 3:32 pm

Re: Creating many templates from one?

Post by Charmie »

Iaits

Fantastic, that's so much simpler then what I was trying to do.
Perfect and thanks loads.

Charmie
gap_tooth_clan

Re: [SOLVED] Creating many templates from one?

Post by gap_tooth_clan »

Was just looking at this, trying to find something else. but here is my 10 cents:

I always use smarty if statements in my templates, it is just the best way. But over use can lead to confusion, always bare in mind the end user and how they will be able to use this.

{if $page_alias == 'home'}

do stuff

{elseif $page_alias == 'contact'}

do other stuff

{elseif $page_alias == 'about-us' || $page_alias == 'services'}

do even more other stuff

{/if}

I also like to find the parent page alias and then add in extra HTML depending on what the parent page is. CMS Made Simple is so very flexible there is always more than one way to achieve a solution to your question, sometimes takes a little searching.
Post Reply

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