I would like to build a multilingual news section where nodes are selected based on availability of a Vorto value in the title field. The goal is to display only those news items which contain text in the current language.
(MVC Razor code is new to me) I'm looking for something along the lines of:
var homePage = CurrentPage.AncestorsOrSelf(2).First();
var newsOverview = homePage.umbNewsOverviews.First();
var newsItems = newsOverview.umbNewsItems.Where(*this is where I'd like to select title items which have a Vorto value).OrderBy....
Is there a way to do this - either with this code, or perhaps an alternate approach?
HasVortoValue available when selecting nodes?
Hi Matt,
I would like to build a multilingual news section where nodes are selected based on availability of a Vorto value in the title field. The goal is to display only those news items which contain text in the current language.
(MVC Razor code is new to me) I'm looking for something along the lines of:
var homePage = CurrentPage.AncestorsOrSelf(2).First();
var newsOverview = homePage.umbNewsOverviews.First();
var newsItems = newsOverview.umbNewsItems.Where(*this is where I'd like to select title items which have a Vorto value).OrderBy....
Is there a way to do this - either with this code, or perhaps an alternate approach?
Best regards,
Steve
Hi again Matt,
I found a solution which seems to work nicely:
IPublishedContent parent = CurrentPage.AncestorOrSelf(2).umbNewsOverviews.First();
var newsItems = parent.Children.Where(x => x.HasVortoValue("title")).OrderBy(x => x.SortOrder);
Of course I'm open to alternatives if you know of a better method.
Thanks again for sharing Vorto.
Best regards,
Steve
Hi Steve,
Nope, that's pretty much how I would do it so I think you've got it pretty spot on.
Good work on figuring it out yourself, I love an inquisitive mind :) #h5yr
Matt
Fantastic. Thanks Matt.
BR, Steve
is working on a reply...