Copied to clipboard

Flag this post as spam?

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


  • Peter van Geffen 54 posts 290 karma points
    Jun 03, 2021 @ 12:55
    Peter van Geffen
    0

    Get current used/picked repository item

    Hey,

    I have a kind of knowledge base. Within these items you can choose a theme from a repository (Video - Article) from a MultiNodeTreepicker.

    Now I want to make an if statement based on which theme is chosen. So roughly the following:

    if(video){
        then this link
    }else if(article){
        then this link
    }else{
        default link
    }
    

    I can read all possible themes, but not a single/current one.

    Who can help me :noob

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jun 03, 2021 @ 14:31
    Dan Diplo
    0

    So a Multi Node Treepicker will return a collection of published content eg. IEnumerable<IPublishedContent> Each of these items will have a corresponding document type. Presumably a Video is a different document type to a Article? In that case you can check the alias to see what type it is an act accordingly:

    So assuming that items is IEnumerable<IPublishedContent> that comes from your MNTP then something like this could work:

            foreach (var item in items)
            {
                if (item.ContentType.Alias == "video")
                {
                    <a href="...">Video Link</a>
                }
                else if (item.ContentType.Alias == "article")
                {
                    <a href="...">Article Link</a>
                }
            }
    
  • Peter van Geffen 54 posts 290 karma points
    Jun 04, 2021 @ 05:01
    Peter van Geffen
    100

    It's just a kind of tag. So they both have the same document type (with, of course, name, description, and a pickable image). So they are the same on the back. It is the image that separates them from the front.

    So now I want to be able to define the link differently based on the name. But your answer and a fresh look in the morning managed to lead me to a result.

    @{
        var themas = item.GetPropertyValue<IEnumerable<IPublishedContent>>("themas");
                foreach (var thema in themas){
                        if(@thema.Name == "Video"){
                                <a href="@item.Url" title="Bekijk video" class="btn btn-readmore readmore-text">Bekijk video</a>
                        }else if(@thema.Name == "Artikel"){
                                <a href="@item.Url" title="Lees artikel" class="btn btn-readmore readmore-text">Lees artikel</a>
                        }else{
                                <a href="@item.Url" title="Lees meer" class="btn btn-readmore readmore-text">Lees meer</a>
                        }
                }
        }
    
  • shekhar sharma 22 posts 110 karma points
    Jun 04, 2021 @ 07:39
    shekhar sharma
    0

    Hi Peter ,

    First of all, allow only one node maximum in you MNTP. Like Below enter image description here

    I believe , In Single Page only 1 theme is allowed. if Yes, Then Run below Variable to get the theme name

    var themeName=Model.Value<>

    if(!string.isNullOrEmpty(themeName)){ if(themeName=video) { // task } else if(themeName=article) { // task } } else { // task }

    Thanks, Shekhar

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies