I was just thinking (and tweeting) 'bout the best way to store site wide settings (once again), web.config or site root node. The latter seems to be the de facto standard.
For multi-site installations I use this uQuery-to get the site root node (level 2):
var siteRootNode = uQuery.GetCurrentNode().GetAncestorOrSelfNodes().FirstOrDefault(node => node.GetDepth()==2);
And to get a setting (integer):
var searchPageNodeId = siteRootNode.GetPropertyAsInt();
I ended up using GetNodeByXPath("//*[@id=" + 1337 + "]) where 1337 is the node id of the master node I'd like to reference. In my environments I find myself referencing the content of a single node from various locations throughout the site, so the use of a 'master' node for holding configurable content in a single place proved highly resourceful.
Fetching homepage Node from NodeFactory
I would like to use the node factory to fetch a node representing the home page.
As the NodeID is not constant (I think). The only way I can see how todo this is with the following
However, this returns a null node.
Whe on the homepage, both the following work to access the node:
However, I dont want to use either of these approaches.
Many Thanks,
Adam
You can use: GetNodeByXPath("//*[@id=" + Node.GetCurrent().Id + "]/ancestor-or-self::doctypealiasoftheroot")
hope it helps :)
Gerty
Thanks Gerty,
That kind'a works :/ I seem to get a paritially filled node object with that query. Here is a copy of the watch in VS
Any ideas?
Should the above xpath expression return a fully populated node object for the homepage?
No idea, i usually use umbraco.library.GetXmlNodeByXPath :)
Thanks Gerty, umbraco.library.GetXmlNodeByXPath works for me :)
I was just thinking (and tweeting) 'bout the best way to store site wide settings (once again), web.config or site root node. The latter seems to be the de facto standard.
For multi-site installations I use this uQuery-to get the site root node (level 2):
And to get a setting (integer):
++ to Gerty for the practical solution.
I ended up using GetNodeByXPath("//*[@id=" + 1337 + "]) where 1337 is the node id of the master node I'd like to reference. In my environments I find myself referencing the content of a single node from various locations throughout the site, so the use of a 'master' node for holding configurable content in a single place proved highly resourceful.
is working on a reply...