Home - News -- News item 1 -- News item 2 - Work -- Work item 1 -- Work item 2 - Play -- Play item 1 -- Play item 2 - Contact - Other
I'm trying to create a macro to pull all level 2 items onto the homepage (i.e. a list containing: News item 1, news item 2, work item 1, work item 2, play item 1 and play item 2) ordered by a datepicker field common to all of the level 2 pages.
I thought I could use umbraco.library:GetXmlNodeById($source) but I'm not sure how to add multiple sources. I then thought I could try listing all level2 pages and filtering by the ids of the appropriate level1 pages, but when I do the following, nothing is returned:
for explanation: with the ancestor selector to level 1 you are selecting the home node. So you can be sure to get the top node from everywhere you are in hte hierachy. After that you are selecting all subnodes of the subnodes fromt he home node => the level 2 nodes You can also do the for-each via
This works, apart from it doesn't order the articles correctly - it's showing all the news ones first, then the work ones etc, even though they should be mixed up. Is it possible to order them so that they're mixed together then ordered?
Get level 2 pages within particular parents
Hi,
I have a site like this:
Home
- News
-- News item 1
-- News item 2
- Work
-- Work item 1
-- Work item 2
- Play
-- Play item 1
-- Play item 2
- Contact
- Other
I'm trying to create a macro to pull all level 2 items onto the homepage (i.e. a list containing: News item 1, news item 2, work item 1, work item 2, play item 1 and play item 2) ordered by a datepicker field common to all of the level 2 pages.
I thought I could use umbraco.library:GetXmlNodeById($source) but I'm not sure how to add multiple sources. I then thought I could try listing all level2 pages and filtering by the ids of the appropriate level1 pages, but when I do the following, nothing is returned:
I thought this would return all level 2 pages, but it appears not.
Could anyone point me in the right direction?
Thanks all...
Not really.. try this:
for explanation: with the ancestor selector to level 1 you are selecting the home node. So you can be sure to get the top node from everywhere you are in hte hierachy. After that you are selecting all subnodes of the subnodes fromt he home node => the level 2 nodes You can also do the for-each via
hth, Thomas
Thanks Thomas, I've modified my code to the following:
This works, apart from it doesn't order the articles correctly - it's showing all the news ones first, then the work ones etc, even though they should be mixed up. Is it possible to order them so that they're mixed together then ordered?
if they have all the attribute articleDate you can do this via
hth, Thomas
Ah-ha! So nearly there yet so far...
Thank again Thomas.
is working on a reply...