Without understanding your structure to much, or what you are trying to do, you might be able to use some of these methods in various combinations to get what you want:
var currentNode = Node.GetCurrent();
//return all children of the currentNode of the specified type
var dt = currentNode.ChildrenAsTable("BlogPost");
//return all children regardless of type var dt = currentNode.ChildrenAsTable();
//return all children as a list var dt = currentNode.ChildrenAsList();
The Program Type nodes are the same level as my Home node. The structure is like this
Content -- Home -- Program type ------- program
Program type and program aren't actually pages. The home page needs to contain a list of all the program types and programs available and I wanted this to be stored in the CMS so it was easy to change.
To dipslay the list on the home page I use an xslt macro and select the program type nodes using
$currentPage/ancestor::root//ProgramType
but I need to do is that in C#.
I have tried getting the parent node of the current one (which should be the root) but it throws an "Object reference not set to an instance of an object."
Selecting nodes of certain document type in .net
Is there a way to select content nodes of a specific document type and their children (different document type) in a .net control.
I have this structure:
Program type
-- program
-- program
Program type
--- program
And I'd like a list of all the "program type" nodes and their child "program" nodes accessible in my .net control. Can I do this?
Without understanding your structure to much, or what you are trying to do, you might be able to use some of these methods in various combinations to get what you want:
Hi Suzyb,
There's a helper library called uQuery in uComponents that has just such method to return a collection of nodes by their document type:
HTH,
Hendy
The Program Type nodes are the same level as my Home node. The structure is like this
Content
-- Home
-- Program type
------- program
Program type and program aren't actually pages. The home page needs to contain a list of all the program types and programs available and I wanted this to be stored in the CMS so it was easy to change.
To dipslay the list on the home page I use an xslt macro and select the program type nodes using
$currentPage/ancestor::root//ProgramType
but I need to do is that in C#.
I have tried getting the parent node of the current one (which should be the root) but it throws an "Object reference not set to an instance of an object."
Hi Suzyb,
There's also a method in uQuery to get nodes by an XPath expression:
($currentPage/ancestor::root//ProgramType would work, but by default this method will run from the root, so can use just //ProgramType)
or to get the root node directly via the nodeFactory you can create it with the id of -1.
HTH,
Hendy
Thanks Hendy
I didn't realise you could select the root node using -1. Using that, this is what I've ended up with.
is working on a reply...