Copied to clipboard

Flag this post as spam?

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


  • Kurt 29 posts 111 karma points
    Dec 08, 2015 @ 19:37
    Kurt
    0

    HTML tags in dictionary?

    Quick rundown: We're working on translating our site. We have a some partial view macro files that need to be translated and can't really be moved into the Content section. So the only other way I know how to get them translated is to use the dictionary.

    Problem: Some of the text in these macro files are strings that include HTML tags, something similar to: "{a href='/info'}Click here{/a} for more information" (curly brackets used instead of <> so that you actually see the HTML tag here). But the html in the dictionary apparently just gets rendered as text. I'd really rather not have 2 separate dictionary items for cases like this. Is there someway to do this? A better/different way?

  • Dennis Aaen 4490 posts 18155 karma points admin hq c-trib
    Dec 08, 2015 @ 19:55
    Dennis Aaen
    100

    Hi Kurt,

    If it´s a link to an internal page, you can use the @Html.Raw method. Then you code should look like this, where you want to output the value of the dictionary item.

    @Html.Raw(Umbraco.GetDictionaryValue("DictionaryItemKey"))
    

    Remember to change the "DictionaryItemKey" so it match your key for your dictionary item.

    You can see and read more about the Html.Raw method here https://umbraco.tv/videos/implementor/working-with-umbraco-data/razor-syntax/htmlraw/

    Hope this helps,

    /Dennis

  • Kurt 29 posts 111 karma points
    Dec 08, 2015 @ 20:09
    Kurt
    0

    Thanks Dennis! That's exactly what I was looking for.

    Out of curiosity, you said "If it´s a link to an internal page...", yet @Html.Raw seems to work even if the link is external. Any reason for your "if"?

  • Dennis Aaen 4490 posts 18155 karma points admin hq c-trib
    Dec 08, 2015 @ 20:12
    Dennis Aaen
    0

    Hi Kurt,

    I just tested it very quickly on an external link, and it´s seems not working for me, but if it works for you then it´s great.

    I am happy that I could help you resolve the case you have.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft