I'm new to Umbraco and XSLT and have watched Pers great videos and read a few documents but have fallen at the first hurdle.
Depending on the active page, I would like to use a macro to render an ID selector to the pages' Body Tag based on a sections' parent node in order to apply CSS styles specific to that section. Thus all children will inherit the correct Body ID for that section and receive the correct styling from the stylesheet. I don't want to enter a property into the document type for the editor to enter each time they create a new article.
There's a few similar posts in the forums but nothing I've tried works. I tried Heather Mills' plugin but it renders a new ID selector for every page rather than each section.
I don't receive any errors but at the same time am not receiving any data. Could someone please point me in the right direction with some really basic tips? Am I using the correct output method?
Here's one of the versions I tried which was very basic:
Heres the code which I got from Heather Mills' dynamic Body ID plugin. As you can see I tried to change the current page id to current page ancestor but without any joy.
This one just puts the nodeName of the level2 ancestor in there but you can take pretty much any value you want, if you can grab it with a "one-liner" XPath selection.
When the body tag is sitting directly in the template, there is no good looking way of doing this (any tag *inside* another tag is definitely not my cup of tea - you ever done any DW templates :-), so I just take what's the fastest way with the least amount of "extras" to keep track of. Creating a separate Macro+XSLT file for this is a little too much for me, especially since the output of said macro is not even going to be "real" XML - you can't generate just an attribute as a result from a transformation so you end up creating a string of text, which is exactly what we accomplish with the Inline XSLT method. It's just as ugly but there's only one place I have to go, should I need o change something.
Hehe...I've done a few DW templates...it was a joy! (not!) ;-)
I usually make the XSLT macro and I feel dirty every time...I think that I'll be using the inline XSLT in the future since it makes more sense to me to do it this way now. I'll probably still feel dirty but maybe not as much. Thanks for the input.
Body ID selector based on ancestor
I'm new to Umbraco and XSLT and have watched Pers great videos and read a few documents but have fallen at the first hurdle.
Depending on the active page, I would like to use a macro to render an ID selector to the pages' Body Tag based on a sections' parent node in order to apply CSS styles specific to that section. Thus all children will inherit the correct Body ID for that section and receive the correct styling from the stylesheet. I don't want to enter a property into the document type for the editor to enter each time they create a new article.
There's a few similar posts in the forums but nothing I've tried works. I tried Heather Mills' plugin but it renders a new ID selector for every page rather than each section.
I don't receive any errors but at the same time am not receiving any data. Could someone please point me in the right direction with some really basic tips? Am I using the correct output method?
Here's one of the versions I tried which was very basic:
Heres the code which I got from Heather Mills' dynamic Body ID plugin. As you can see I tried to change the current page id to current page ancestor but without any joy.
Any tips really apprecaited!
Hi eddy,
Wow, that's a truckload of code :-)
I've been doing this with a snippet of Inline XSLT for a long time and it "just" works - it's done right in the template:
This one just puts the nodeName of the level2 ancestor in there but you can take pretty much any value you want, if you can grab it with a "one-liner" XPath selection.
/Chriztian
Hi Chriztian
May I ask why you prefer to make the XSLT inline? Is there any particular reason?...Just being curious :-)
/Jan
Of course Jan,
When the body tag is sitting directly in the template, there is no good looking way of doing this (any tag *inside* another tag is definitely not my cup of tea - you ever done any DW templates :-), so I just take what's the fastest way with the least amount of "extras" to keep track of. Creating a separate Macro+XSLT file for this is a little too much for me, especially since the output of said macro is not even going to be "real" XML - you can't generate just an attribute as a result from a transformation so you end up creating a string of text, which is exactly what we accomplish with the Inline XSLT method. It's just as ugly but there's only one place I have to go, should I need o change something.
Hope that's helpful-
/Chriztian
Hehe...I've done a few DW templates...it was a joy! (not!) ;-)
I usually make the XSLT macro and I feel dirty every time...I think that I'll be using the inline XSLT in the future since it makes more sense to me to do it this way now. I'll probably still feel dirty but maybe not as much. Thanks for the input.
/Jan
Chriztian - worked like a charm! Thank you so much.
Eddy
is working on a reply...