Seems mad now, but I once did this for this same problem:
var filteredNext = new DynamicNode(Model.Id).GetFollowingSiblingNodes().Where(x => x.GetProperty("umbracoNaviHide").Value != "1");
if (filteredNext.Any())
{
<p>next not hidden: @filteredNext.First().Url</p>
}
what I want from Next node from "Opaque 14x9" would be Plastic.. this wouldn't be retreived by GetFollowingSiblingNodes as plastic is a parent not sibiling??
So I'd have to start doing a lot of branching... depenadnat on if the sibling/descendant/parent/ancestor had the properties I wanted (like visible) hence why I suggested a get the sitemap for you filter and then skip to/take the next node?
Not sure which approach might be more efficient.. but I think we'd need more than next/prev sibling for this to work?
Next Siblings where Visible
Hi guys,
I need to create a Next & Previous button but somehow forgot about visible or not!!
Can someone point out how do i get next or previous button to jump to the next or previous visible node if any is present to work.
Tried something like this but
Even tried that
Hey Fuji
What is m? DynamicNode, strongly typed IPublishedContent?
This is how I would possibly do it, get all the nodes in a collection that are visible then do a loop over that, like so.
Hey Warren,
Nope not exactly what i was trying to achieve here. Well i have the following struc
So let says am on Article 1 i should be able to get a Next Button which will redirect me to Article 4.
Hmm wonder what happens if you just do
@Current.Next().Visible()
or this
@Current.Parent.Children.Where(x => x.Visible) (Not ideal as going upto the parent)
Warren
Did something like this
But here its not jumping to the next visible node.
Btw Current.Next().Visible() aint working for me am on 4.11
From the previous post it is actually working but am not able to get the right URL .
Hey Fuji,
This is because it is just getting the next node regardless of the value of umbracoNaviHide.
Hence you probably need to try and do this:
@Current.Parent.Children.Where(x => x.Visible)
what about an alternative approach.. get all your descendants from the homepage Nodelike a site map.. then skipt to yout currenr and find prev/next
Seems mad now, but I once did this for this same problem:
Hi Jeavon,
What did you use to get "GetFollowingSiblingNodes " ? Are you using uComponents here ?
Hi Fuji,
It's in umbraco.NodeExtensions so you just need to add @using umbraco; to the top of your Razor file.
Thanks,
Jeavon
Is this not in v6 ? Cos am actually on a v 4.11 version.
Nope, v4.8+ :-)
Full example:
My Mistake!!
instead of
Thanks Jeavon
Cool, you can of course do a simular thing for the previous link with the GetPrecedingSiblingNodes method
Forgive me if I'm worng.. but say...
what I want from Next node from "Opaque 14x9" would be Plastic.. this wouldn't be retreived by GetFollowingSiblingNodes as plastic is a parent not sibiling??
So I'd have to start doing a lot of branching... depenadnat on if the sibling/descendant/parent/ancestor had the properties I wanted (like visible) hence why I suggested a get the sitemap for you filter and then skip to/take the next node?
Not sure which approach might be more efficient.. but I think we'd need more than next/prev sibling for this to work?
Hi Mike, absolutely, if you wanted to navigate through different levels of the tree using Previous and Next then you would need a filterable sitemap!
Which is painful in razor... http://our.umbraco.org/forum/developers/razor/35909-xslt-to-razor-conversion-issues-order-of-enumeration-of-descendants
http://issues.umbraco.org/issue/U4-1151
:-(
Yea i would be using DynamicNode and then just use the methods on that :)
The code I suggested does the same as the standard .Next() method but allows you to filter beforehand
is working on a reply...