Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steve 140 posts 321 karma points
    Jun 04, 2014 @ 05:21
    Steve
    0

    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 

  • Steve 140 posts 321 karma points
    Jun 04, 2014 @ 06:40
    Steve
    1

    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

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jun 04, 2014 @ 08:57
    Matt Brailsford
    100

    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

  • Steve 140 posts 321 karma points
    Jun 04, 2014 @ 15:26
    Steve
    0

    Fantastic. Thanks Matt.

    BR, Steve

Please Sign in or register to post replies

Write your reply to:

Draft