Bummer. So, it sounds like an XSLT macro would actually be easier. Determine the level, set the class name as a text string which drops into the template.
Another way round it would be to make use of http://our.umbraco.org/projects/backoffice-extensions/cogworks-cogcsspickerdatatype then to your master doctype (if you have one or doctype you are working with) add a datatype of type cogcsspicker. Then create css files for your levels with that definition and assign the css to your documents then update the template to pick that css up. Bit more work but no need for code.
Conditional CSS in Master Template
In my base template I need to change the CSS class based upon the node's level. For instance, for pages that are one level deep, I want this:
and for all other levels, I want this:
Without using XSLT and a macro, is there a simple way to accomplish this?
Hi Connie,
Yes you can do this, but it's not the easiest of methods and would involve two master templates.
You'd use a Document_New event handler which would then detect the document's level and assign the template programmatically - something like:
Best,
Benjamin
Bummer. So, it sounds like an XSLT macro would actually be easier. Determine the level, set the class name as a text string which drops into the template.
<div id="main" <umbraco:Item field="pageName" xslt="concat('class="inner', $currentPage/@level, '"')" runat="server"></umbraco:Item>>
</div>
Connie,
Another way round it would be to make use of http://our.umbraco.org/projects/backoffice-extensions/cogworks-cogcsspickerdatatype then to your master doctype (if you have one or doctype you are working with) add a datatype of type cogcsspicker. Then create css files for your levels with that definition and assign the css to your documents then update the template to pick that css up. Bit more work but no need for code.
Regards
Ismail
is working on a reply...