I'm using 7.1.4, i'm trying to get the last sibling of the current page in my navigation so that if there is no previous page it goes to the last page,
Thanks for the reply, sorry if i wasn't clear enough. What i am trying to find is the last node on the same level i am currently on, `@CurrentPage.AncestorOrSelf(1).Children.Last().Url takes me up a level.
my structure is:
Home
About
Work
Blog
Blog Article 1
Blog Article 2
Blog Article 3
Blog Article 4
Contact
The navigation is on the Blog Articles, its a left and right arrow enabling users to scroll to the next/previous article, when im on Article 1 i want the left arrow to go to the last Article, the code you have given takes me from Blog Article 1 to Contact.
Navigating to last sibling node
Hi,
I'm using 7.1.4, i'm trying to get the last sibling of the current page in my navigation so that if there is no previous page it goes to the last page,
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div class="case-controls">
@if (@CurrentPage.Previous() != null) {
<a href="@CurrentPage.Previous().Url"><img src="/images/shared/left-icon.gif" alt="" /></a>
}
else{
<a href=""><img src="/images/shared/left-icon.gif" alt="" /></a>
}
<a href="@CurrentPage.Parent.Url"><img src="/images/shared/grid-icon.gif" alt="" /></a>
@if(@CurrentPage.Next() != null){
<a href="@CurrentPage.Next().Url"><img src="/images/shared/right-icon.gif" alt="" /></a>
}
else{
<a href="@CurrentPage.Up().Down().Url"><img src="/images/shared/right-icon.gif" alt="" /></a>
}
</div>
Any help would be greatly appreciated.
Thanks!
Hi Kerri.
If I have understood your question correctly, then when there is no previous pages, then you want a link to the last page on the same level.
If so I think that I have found a way that you could do it.
Hope this helps, if you have any further questions don't hesitate to ask again.
/Dennis
Hi Dennis,
Thanks for the reply, sorry if i wasn't clear enough. What i am trying to find is the last node on the same level i am currently on, `@CurrentPage.AncestorOrSelf(1).Children.Last().Url takes me up a level.
my structure is:
Home
About
Work
Blog
Blog Article 1
Blog Article 2
Blog Article 3
Blog Article 4
Contact
The navigation is on the Blog Articles, its a left and right arrow enabling users to scroll to the next/previous article, when im on Article 1 i want the left arrow to go to the last Article, the code you have given takes me from Blog Article 1 to Contact.
Thanks again!
Kerri
Hi Kerri,
What about this:
Did the code do what you are after, I hope so.
/Dennis
Thanks Dennis - this works!
is working on a reply...