I have a macro that is pulling in nodes that have been selected from a tree picker into a type of news feed for the page that it is placed on. I am trying to add the value of the parent of the "NewsArticle", which would be the "NewsCategory" and output the value of the category to the individual items in the "NewsFeed".
Here is the xslt, but I am not getting any output from the value-of select statement.
If your NewsCategory nodes are just simple nodes with only the pageTitle property, only categories that have the pageTitle set will output anything (because the code is testing the string value of the $node, which is all of its text() node children).
First, change the test to test for a node instead of its value:
I always thought that $currentPage/ancestor::Homepage would first get the listing of ancestors of the currentPage that are on the Homepage axis, is that the correct way of thinking?
Not quite - the "axis" is the ancestor[-or-self]:: part - Homepage is what you're looking for along that axis. Have a play with the XPath Axes Visualizer to get familiar with what's selected... :-)
XPath Confusion
I have a macro that is pulling in nodes that have been selected from a tree picker into a type of news feed for the page that it is placed on. I am trying to add the value of the parent of the "NewsArticle", which would be the "NewsCategory" and output the value of the category to the individual items in the "NewsFeed".
Here is the xslt, but I am not getting any output from the value-of select statement.
Hi Steve,
If your NewsCategory nodes are just simple nodes with only the pageTitle property, only categories that have the pageTitle set will output anything (because the code is testing the string value of the
$node
, which is all of its text() node children).First, change the test to test for a node instead of its value:
Provided your picked nodes exist (and are published) you should now see some output.
Now, you could try refactoring the code to get rid of the choose altogether:
If this doesn't work, we should have a look at how you're getting the ids for the picked nodes...
/Chriztian
Nope, unfortunatly that didn't produce any output.
The structure is: (nodes are by document type)
<root>
<Academics>
<SomeAcademicItem>
<SomeAcademicNews></SomeAcademicNews>
</SomeAcademicItem>
<Academics>
<NewsHome>
<NewsCategory>
<NewsArticle></NewsArticle>
</NewsCategory>
</NewsHome>
</root>
Also, the macro that is pulling the NewsCategory items in, is placed on the "SomeAcademicNews" page, if that makes a difference.
I thought the xpath using $currentNode/ancestor-or-self:: would have gotten out to the root, doesn't it?
I've got it working with this xpath, but as I said I thought it would be already starting from the root with $currentPage/ancestor-or-self.
Hi Steve,
Ah - that's it then.
Nope - that won't do, because the NewsHome node is not an ancestor of the SomeAcademicNews node - but here's the fix:
Create a variable at the top level - e.g. just after the currentPage param:
Then use that as the base when selecting the category:
Let me know if that does it,
/Chriztian
That works!! I guess I just don't understand xpath axies.
I always thought that $currentPage/ancestor::Homepage would first get the listing of ancestors of the currentPage that are on the Homepage axis, is that the correct way of thinking?
Awesome - great that it works.
Not quite - the "axis" is the ancestor[-or-self]:: part - Homepage is what you're looking for along that axis. Have a play with the XPath Axes Visualizer to get familiar with what's selected... :-)
/Chriztian
is working on a reply...