Find ID of node from node name Options
dan
Posted: Wednesday, January 02, 2008 9:50:58 PM
Rank: Enthusiast

Joined: 12/15/2007
Posts: 20
Hi all,

I've been using the code http://en.wikibooks.org/wiki/Umbraco/Samples_and_Articles/Creating_umbraco_pages_programmatically to add pages to Umbraco.

I have a category, subcategory, page structure that I want to import into Umbraco. Using the above code I can add all the pages under a node when I know it's ID. My question is how do I find the ID of a node using only it's name. Is there a way I can adjust the above code so I can pass in a name only and get the node ID to use as the parent ID?

My problem is that I can only create one level at a time by manually working out what the ID of the parent node is, if I could do this programmatically I could import the entire structure into Umbraco in one go.

Regards,

Dan
dan
Posted: Wednesday, January 02, 2008 10:32:55 PM
Rank: Enthusiast

Joined: 12/15/2007
Posts: 20
Found a solution

Code:

'get id from a node using the name
For Each child As umbraco.presentation.nodeFactory.Node In nodes
    If child.Name = "page name goes here" Then
        Response.Write(child.Id)
    End If
Next

Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.