Template paths Options
mortenbock
Posted: Monday, April 28, 2008 12:27:31 PM

Rank: Addict

Joined: 7/19/2006
Posts: 706
Location: Århus, Denmark
I just got a idea from this thread:

http://forum.umbraco.org/yaf_postst4775_Alternative-Templates--Advice-Needed.aspx

The thing is that a template can only have _one_ master template, so if you want to make use of the same template with different masters, you would have to duplicate your template, which would again force you to maintain two sets of identical templates.

Mu suggestion is actually pretty simple.

You still create templates in exactly the same way that we are used to, but we introduce a meta layer on top of it.

So if I have these templates:

-xhtmlMaster
-printMaster
-LeftMenu
-textPage

A normal page would typically be rendered with textPage -> LeftMenu -> xhtmlMaster. And if I wanted to use my printMaster, then I would need to duplicate my LeftMenu and textPage templates.

If we introduce a "Template Path" then I could define a set of templates that should be linked together like this:

MyNormalPath: textPage -> LeftMenu -> xhtmlMaster (this is not necessary since it is the default path)
MyPrintPath: textPage -> printMaster

It could then be applied with the exact same syntax as the altTemplate.

So /page.aspx?altTemplate=MyPrintPath or /page/MyPrintPath.aspx would check if there is at template OR a template path with that alias, and then apply that set of templates.

What do you think? Would this be cool for at future version of Umbraco?

Morten Bock - Level 2 certified - My danish blog with a few english posts | CodeGarden on Facebook
drobar
Posted: Monday, April 28, 2008 3:07:08 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,285
Location: KY, USA
I've often wanted to do something rather similar, and this approach might work there as well (or maybe there's another approach I haven't found yet?)

I keep my templates very segmented:

1. Document
2. Layout
3. TextPage

Each bubbles up so that 'Document' is master of 'Layout', which is a master for 'TextPage'. The trouble is, sometimes it is the 'Layout' template that needs to have a few variations (with or without a banner image, with or without a global navigation bar or search box, for instance).

This means I end up having 'Layout A', 'Layout B', and 'Layout C'. And thus... I need to duplicate the 'TextPage' template as well so that I can assign the appropriate master Layout tempate. In this scenario, I end up with seven templates... of which the three TextPage templates are absolutely identical except for the specified master template.

This scheme is works fine, but it is extra maintenance and I'd prefer a more elegant solution if one could be found. Perhaps using Morten's "TemplatePath" could do it, especially if it could be set via a macro.

All suggestions welcome!

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
VirtualRichard
Posted: Monday, April 28, 2008 3:44:20 PM

Rank: Aficionado

Joined: 9/17/2007
Posts: 172
Location: London, UK.
Sounds good to me.

What I am finding is that the pages within the site I am constructing are very varied in terms of the design, so I am ending up with lots and lots of templates. The thought of having to maintain multiple variations of these is not one I am entertaining...

Our site must be available to pretty much everyone whether blind, on a mobile phone or sitting at a 30" Mac. The challenge is to do this while using a set of templates with as few alternatives / duplications as possible.

Richard

2 * 3 * 3 * 37 : The prime factorisation of The Beast.
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.