Okay here is an example of how you could do it. I have just taking it from my Umbraco certification Umbraco installation.
So create a scripting file cshtml in with an associated Maco in the developer section, make your modifications to the code, so it fetch your document type called News. And then insert the macro in the template where all news to display
Get top 10 document type DESC
Hi guys. Hope you can help me with this one. Bit of a noob
I have a document type called "News". I would like to get the top 10 latest news document types in the a descending order.
.
Hi Høgni,
You can do it by using XSLT or Razor.
In XSLT you could do something like this:
Or you could do it Razor:
And I think something like the should work for you: If your are using Razor macro scripts and Master pages, and not MVC.
<ul>
@foreach (var item in Model.News.Where("Visible").OrderBy("Name desc").Take(10)){
<li>
<ahref="@item.Url">@item.Name</a>
</li>
}
</ul>
I hope this can help you further.
/Dennis
Hi thankyou for the answer. It was a Razor soulition i was looking for. But i cant seem to get anything form the foreach loop :/
Hi Høgni,
Okay here is an example of how you could do it. I have just taking it from my Umbraco certification Umbraco installation.
So create a scripting file cshtml in with an associated Maco in the developer section, make your modifications to the code, so it fetch your document type called News. And then insert the macro in the template where all news to display
And in my case the document type is called NewsItem. This is an example should work if you not running MVC.
/Dennis
is working on a reply...