Render child-items in different partial views according to doc type
Hi
I'm building a website where i need to load several child-items in different partial views and i need it to be possible to change the order of the child-items. Is there any "best pratices" for that?
Here are an exaple on how it could looks like where it sort on the name of the nodes:
<ul> @* OrderBy() takes the property to sort by *@ @foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("Name")) { <li><a href="@page.Url">@page.Name</a></li> } </ul>
Render child-items in different partial views according to doc type
Hi
I'm building a website where i need to load several child-items in different partial views and i need it to be possible to change the order of the child-items. Is there any "best pratices" for that?
Hi Marianne and welcome to our,
You can use the OrderBy in you foreach loop. The OrderBy orders a collection by a field name.
Take a look at these cheat sheets, I know it says version 6, but you can use it for version 7 too. There are both cheat sheets, for dynamic version of Razor and for the strongly typed version. http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets
Here are an exaple on how it could looks like where it sort on the name of the nodes:
<ul>
@* OrderBy() takes the property to sort by *@
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("Name"))
{
<li><a href="@page.Url">@page.Name</a></li>
}
</ul>
Hope this helps,
/Dennis
is working on a reply...