How do i get all the sibling nodes of a particular node using razor
Use Case:
Lets say that I am in a page named Package 1 and Package 1 is a child node of HomeCleaning. My requirement is to find all the child nodes of HomeCleaning, including Package1 and then list the property name "Package Name" in this page.
ScreenShot of Contents Page
I have tried different options to get the template code using razor. But none of them have worked. This is the last one that I have worked on.
Thank you. that works absolutely great. Is there any good documentation that I can refer to know more about Umbraco nodes and models. Its a bit confusing for me
Get sibling nodes in razor
Hello,
How do i get all the sibling nodes of a particular node using razor
Use Case:
Lets say that I am in a page named Package 1 and Package 1 is a child node of HomeCleaning. My requirement is to find all the child nodes of HomeCleaning, including Package1 and then list the property name "Package Name" in this page.
ScreenShot of Contents Page
I have tried different options to get the template code using razor. But none of them have worked. This is the last one that I have worked on.
<ul id="sidebarMenu">
@{
Node node = Node.GetCurrent();
var siteRoot = CurrentPage.Ancestors();
var child = siteRoot.Children;
foreach (var item in child)
{
<li><a href="">@item.packageName</a></li>
}
}
</ul>
Any help is much appreciated.
Thank you,
Libin
I assuming Umbraco6 - but you should just need to go up to the CurrentPage parent, and then list all children
Thank you. that works absolutely great. Is there any good documentation that I can refer to know more about Umbraco nodes and models. Its a bit confusing for me
Everything I know started here http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets it's a bit old but gives you the basics.
Then the core documentation is starting to take shape for MVC Stuff.. http://our.umbraco.org/documentation/Reference/Templating/
and the PDF cheatsheets are handy. http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets
Libin Are you in razor view? You should be able to do @Model.children? Any way i would write the code as
is working on a reply...