Copied to clipboard

Flag this post as spam?

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


  • Joshua McBride 5 posts 85 karma points
    Jun 19, 2018 @ 20:20
    Joshua McBride
    0

    Tags Data Type - Display on Content Page

    Hi all,

    I have a data type set with the name blogTags

    I want to display its contents in a list, as below;

    <ul class="entry-meta">                 
    <li class="cat"><a href="">Wordpress</a></li>
    <li class="cat"><a href="">Design</a></li>          
    </ul>
    

    I've tried a couple of forum solutions, but cannot seem to get any of them to work, they either return compilation error or just displays the following System.String[]

    The forum post i've tried most recently is this one here.

    Any help would be appreciated!

    Thanks

    Josh

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 19, 2018 @ 21:04
    Jan Skovgaard
    0

    Hi Joshua

    I just gave this a try on Umbraco 7.10.4 with an instance of the tag datatype where the output is set to be "CSV".

    By using the following syntax I was able to render the tags

        @if(Model.Content.BlogTags.Any()){
        <ul>
        foreach(var tag in Model.Content.Tags){
            <li class="cat">
                 <a href="[email protected]()">@tag</a>
            </li>
        }
       </ul>
    }
    

    I hope this helps!

    /Jan

  • Joshua McBride 5 posts 85 karma points
    Jun 19, 2018 @ 21:41
    Joshua McBride
    0

    Hi Jan,

    Do I need to modify this to make it work? I'm getting a compilation error still..

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'blogTags' and no extension method 'blogTags' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

    Thanks!

    Josh

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 20, 2018 @ 04:11
    Jan Skovgaard
    0

    Hi Joshua

    Can you please paste the entire code you're writing for this? I'll need to see the content of the whole file. This way I can better pinpoint to you where things go wrong.

    But I notice that the error is saying "blogTags"...starting with a lowercase b...You should write "BlogTags" like in the example - If you actually have done that I'm not sure that your property alias of the tag datatype is called "blogTags" - Then please doble check that you're targeting the correct alias.

    Looking forward to hearing from you.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft