|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
Hi I new in Umraco but I'm familiar with concept but I need some tips ... my contents look like  now I want to build a user component on that will be used for navigation trough all pages in the same chapter. so this user control should be in template of all pages type documents. my problem is next how can I found the current page nodeId form Umraco API? And more importand how to make link on previous and next page (accualy to previous and next node in the same branch). It have to be user control becouse I will going to have some bussines logic here (like stored some data in DB ect...) is there any similar solution on forum or some tips or example of code will be great HELP
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 670 Location: Preston, UK
|
lpastor, You need nodefactory Code: umbraco.presentation.nodeFactory.Node.GetCurrent().Id
ps you can get api documentation here Regards Ismail
Level 2 certified. If it aint broke dont fix.
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
hi Ismail
yes but how can I found next or previous Node in the same level and make nice URL of it ?
example: on page3 get link to page2 and page4 (see picture above)
thanks
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
Any idea ???
|
|
 Rank: Aficionado
Joined: 7/19/2006 Posts: 165
|
lpastor wrote:Any idea ??? It is pretty straightforward Code:using umbraco.presentation.nodeFactory;
Node currentNode = Node.GetCurrent(); Node parentNode = currentNode.Parent; Nodes nodes = parentNode.Children;
foreach (Node node in nodes) { bool isCurrentNode = node.Id == currentNode.Id; if (isCurrentNode) { Response.Write("<strong>"); }
Response.Write(node.Name); Response.Write("<br />"); if (isCurrentNode) { Response.Write("</strong>"); } }
CPalm, www.cpalm.dk
|
|
 Rank: Aficionado
Joined: 8/4/2008 Posts: 111 Location: Serbia
|
it is working like a charm :-)
Thanks a lot ...
probably silly question but how can I use that niceUrl (umbraco.library:NiceUrl(@id)) method from API to make a link
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 670 Location: Preston, UK
|
umbraco.library.NiceUrl
Regards
Ismail
Level 2 certified. If it aint broke dont fix.
|
|
 Rank: Newbie
Joined: 9/2/2008 Posts: 1 Location: Denmark
|
I tried the above example.
For some reason I get a "System.NullReferenceException: Object reference not set to an instance of an object.".
It is the line of 'Nodes nodes = parentNode.Children;', in other words parentNode is 'null'.
Can anybody tell me how this can happen? I think I must have misunderstood something basic here...
Mkkl.
|
|
Rank: Newbie
Joined: 9/5/2008 Posts: 9 Location: Chattanooga, TN
|
For anyone that stumbles here and has the same problem as staunsholm, I think it has to do with the root node returning as null, so if you're trying this from a level 1 node it might not work. Have a workaround at: http://forum.umbraco.org/yaf_postsm32556_Can-I-use-NodeFactory-to-get-the-root-directory.aspx#32556
|
|
|
Guest |