I want to list items by a specific nodetypealias, is this possible? I've tried this, however, it says that the NodeTypeAlias doesnt exist in the current context:
@foreach(var item in @Model.NodeById(1064).Children.Where(NodeTypeAlias == "NewsItem").Take(itemsPerPage).OrderBy("NewsDate desc"))
Both @seb's approach and @jeroen's aproach are correct, but I do prefer the second one just because is shorter and easier to read. There's a third option that is to "pluralize" the node type alias, like this:
@foreach(var item in @Model.NodeById(1064).NewsItems.Take(itemsPerPage).OrderBy("NewsDate desc"))
The matter of taste, as for me pluralising/singularising look a bit far too smart - I wonder how the nouns like "mouse", "goose", "sheep", "pants", etc would read in this case :-)
List items by a specific NodeTypeAlias?
Hi guys...
I want to list items by a specific nodetypealias, is this possible? I've tried this, however, it says that the NodeTypeAlias doesnt exist in the current context:
@foreach(var item in @Model.NodeById(1064).Children.Where(NodeTypeAlias == "NewsItem").Take(itemsPerPage).OrderBy("NewsDate desc"))
You're almost there:
@foreach(var item in @Model.NodeById(1064).Children.Where("NodeTypeAlias == @0", "NewsItem").Take(itemsPerPage).OrderBy("NewsDate desc"))
Won't this also work?
Think it than only uses children which are of type "NewsItem". It's a little bit shorter.
Jeroen
Both @seb's approach and @jeroen's aproach are correct, but I do prefer the second one just because is shorter and easier to read. There's a third option that is to "pluralize" the node type alias, like this:
The matter of taste, as for me pluralising/singularising look a bit far too smart - I wonder how the nouns like "mouse", "goose", "sheep", "pants", etc would read in this case :-)
is working on a reply...