I've started to develop a lot of solutions, where one backend instance is used to administrate several sites. And there's one problem I always seem to run into, and haven't figured out the best way of solving yet:
Imagine that you fx. want a "Latest News" box on each page on each site. They way to do this is to take the Top Node/Homepage, do a descendant-or-self::node to find all nodes of type "News", order it by date and show the top 3.
But how do I figure out what the Top Node/Homepage is of the current site? What's the best way to do this?
Finding the ID of the homepage/top node
Hi there,
I've started to develop a lot of solutions, where one backend instance is used to administrate several sites. And there's one problem I always seem to run into, and haven't figured out the best way of solving yet:
Imagine that you fx. want a "Latest News" box on each page on each site. They way to do this is to take the Top Node/Homepage, do a descendant-or-self::node to find all nodes of type "News", order it by date and show the top 3.
But how do I figure out what the Top Node/Homepage is of the current site? What's the best way to do this?
Hopes it makes sense :-)
Best regards,
Soeren S.
Soeren,
How about this code snippet:
Does that help?
Cheers,
/Dirk
Hi Søren
I use this variable to get the ID of the top node of a tree
Brilliant!
I chose to go with a variation of Linaa's example:
Thanks guys, been needing this simple stuff for some time now :-)
/SoerenS
is working on a reply...