how to set a variable if a node's ancestor has a certain name
I need to set the value of a variable based on whether one of the ancestors of the current node has a certain name, and if the parent of that ancestor with the certain name has a certain name. How do I traverse the ancestors of the current node to test these two conditions?
I tried this but the because the leveltest variable is out of scope in the second for-each loop. Also, I don't even know if i'm getting the syntax right for matching the nodename of the ancestors. New to xslt so any help would be appreciated.
Umbraco 4.7. And yes, trying to render a breadcrumb that needs to be adjusted for a branch. I've got a client who wants to build a microsite with separate navs and breadcrumb trail. I tried putting both the main site and the microsite at the root level, but naming subnodes the same thing (a necessity), such as Careers, always renders the links to the main site's Careers page. Of course, I also tried to not hide the top level path, but then I get the ugly "home" root directory on the main site, which is undesirable.
My best solution was to put the mircosite at the L2 depth, and I can get breadcrumb and navs to work right as long as I change the level at which I start when in the microsite's branch. It works fine when I'm at the root of the microsite on that branch, but the child nodes of that root don't know it's there unless I traverse up to it, matching names as I go until I find it, and until I make sure it's the microsite by checking to see if the parent's name is 'Home.'
That worked perfectly. I've been coding a long time, but am still learning the xslt syntax. So, when you do the initial select for the isMicroSite variable, that call traverses the branch based on ancestor-or-self directive? I think that's where I was getting confused. I was thinking I had to loop through it somehow with a for-each, where instead you just do the select. Thanks for the help!
how to set a variable if a node's ancestor has a certain name
I need to set the value of a variable based on whether one of the ancestors of the current node has a certain name, and if the parent of that ancestor with the certain name has a certain name. How do I traverse the ancestors of the current node to test these two conditions?
I tried this but the because the leveltest variable is out of scope in the second for-each loop. Also, I don't even know if i'm getting the syntax right for matching the nodename of the ancestors. New to xslt so any help would be appreciated.
Hi Neil,
Which version of Umbraco are you using?
Are you trying to render a breadcrumb of some sorts but needing to adjust it on a specific branch of the site, maybe?
/Chriztian
Hi Chriztian,
Umbraco 4.7. And yes, trying to render a breadcrumb that needs to be adjusted for a branch. I've got a client who wants to build a microsite with separate navs and breadcrumb trail. I tried putting both the main site and the microsite at the root level, but naming subnodes the same thing (a necessity), such as Careers, always renders the links to the main site's Careers page. Of course, I also tried to not hide the top level path, but then I get the ugly "home" root directory on the main site, which is undesirable.
My best solution was to put the mircosite at the L2 depth, and I can get breadcrumb and navs to work right as long as I change the level at which I start when in the microsite's branch. It works fine when I'm at the root of the microsite on that branch, but the child nodes of that root don't know it's there unless I traverse up to it, matching names as I go until I find it, and until I make sure it's the microsite by checking to see if the parent's name is 'Home.'
Allright - it makes sense now;
Be sure to express this in the code (variable names etc.) - something like this should do:
/Chriztian
That worked perfectly. I've been coding a long time, but am still learning the xslt syntax. So, when you do the initial select for the isMicroSite variable, that call traverses the branch based on ancestor-or-self directive? I think that's where I was getting confused. I was thinking I had to loop through it somehow with a for-each, where instead you just do the select. Thanks for the help!
is working on a reply...