Copied to clipboard

Flag this post as spam?

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


  • Thomas Eriksen 1 post 71 karma points
    Aug 12, 2023 @ 08:30
    Thomas Eriksen
    0

    Tags rendered as systemstring[]

    Hi!

    I've created a property with tags and added a Razor shortcode : @Model.Value("huskeliste") in my template but each tag is being rendered as : System.String[]

    I have textareas that work fine.

    I'm using version 12.

    What's going on?

    Thanks in advance.

    Thomas

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Aug 13, 2023 @ 08:31
    Huw Reddick
    1

    Hi Thomas,

    Your tag property will be an IEnumerable list, so render it like this

    @if(Model.Huskeliste.Any()){
        <ul>
            @foreach(var tag in Model.Huskeliste){
                <li>@tag</li>
            }
        </ul>
    }
    

    see here

    https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/tags

  • Carl 5 posts 85 karma points
    Oct 25, 2023 @ 15:41
    Carl
    0

    The answer from Huw helped me solve the same problem. needed to use the second example in the link. this worked for me.

    @{
    if (Model.HasValue("keywords"))
    {
        string keywordstring = "";
        var keywords = Model.Value<IEnumerable<string>>("keywords");
        foreach (var keyword in keywords)
        {
           keywordstring += keyword + ",";
        }
        <meta name="keywords" content="@keywordstring" />
    }}
    
Please Sign in or register to post replies

Write your reply to:

Draft