Preset Template Properties Options
VirtualRichard
Posted: Wednesday, February 27, 2008 5:43:42 PM

Rank: Fanatic

Joined: 9/17/2007
Posts: 264
Location: London, UK.
I have a master template that can be simply represented thus:

<div id="foo" class="bar">

{CHILD TEMPLATES RENDER HERE}

</div>

I want child templates to be able to change the class "bar" of the master template.

I know how to do this by using a recursive field property but I don't want to require content creators change the class name - that will never work!

What I want to do is set this value in the document types / template / whatever so the property will be automatically populated whenever a page is created in the CMS 'Content' section.

Thanks in advance for any help,

Richard


2 * 3 * 3 * 37 : The prime factorisation of The Beast.
drobar
Posted: Wednesday, February 27, 2008 5:58:32 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
There's no way for a child template to modify its parent/master. But here's a sneaky way to do this...

Use the TemplateId. This will always be the id of the child template, not any of its parents/masters.

Then, add that macro to your master template's <div> tag as part of the class. Remember to prefix it with some text because classes can't start with digits.

I use the following...
Code:

<div id="Main" class="Template<?UMBRACO_GETITEM field="template"/>">
    <?UMBRACO_TEMPLATE_LOAD_CHILD/>
</div>



In my css I have entries like:
Code:

.Template1045 p {
    margin: 0;
    padding: 0 17px 8px 12px;
    }


cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
dawoe
Posted: Wednesday, February 27, 2008 7:18:05 PM

Rank: Aficionado

Joined: 1/19/2008
Posts: 170
Location: Belgium
If it's only javascript or css you need to change you can also use this approach.

http://dawoe.blogspot.com/2008/01/adding-css-or-javascript-to-your.html

Probably can fit your needs too.

Converting a DotNetNuke site to Umbraco : Follow it here
VirtualRichard
Posted: Thursday, February 28, 2008 11:20:21 AM

Rank: Fanatic

Joined: 9/17/2007
Posts: 264
Location: London, UK.
Hi, thanks, I've raised a new work item so hopefully this functionality can be added:

I think it must be an easy addition. Just a new data type (type of label?) that is applied by the developer, not the content creator.

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.