4
@foreach (var item in Model.Content.Children.Where("Visible"))
            {
                <a title="@item.Name" href="@item.Url">@item.Name</a>
            }

This does not give the result I need.

Q: How can I get all the all siblings pages from current page?

alex
  • 1,300
  • 1
  • 29
  • 64

1 Answers1

12

Try this:

@var siblings = Model.Content.Siblings()

@foreach (var item in siblings.Where(x => x.Id != Model.Content.Id))
{
    <a title="@item.Name" href="@item.Url">@item.Name</a>
}
Digbyswift
  • 10,310
  • 4
  • 38
  • 66
  • Thanks! how can I get all siblings except current page? – alex Sep 05 '14 at 08:57
  • Kind of strange that siblings would include itself! – Sébastien Richer Sep 05 '14 at 13:39
  • I guess it depends on how you look at it. I assumed the same as you, but it could also mean "the siblings" as opposed to the content's siblings. Having said that, there is already `.Ancestors()` and `.AncestorsOrSelf()` so maybe it should be `.Siblings()` and `.SiblingsOrSelf()`? – Digbyswift Sep 05 '14 at 13:49