Copied to clipboard

Flag this post as spam?

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


  • Damion 96 posts 331 karma points
    Oct 23, 2019 @ 13:45
    Damion
    0

    Dictionary items not displaying

    Hi,

    When I have a view or partial which does not inherit from IPublishedContent, ie inherits from a custom view modeI, I cannot seem to display dictionary items in the usual:

    @Umbraco.GetDictionaryValue("MyItem", "alt text")
    

    How can I get round this?

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Oct 26, 2019 @ 07:08
    Marc Goodson
    0

    Hi Damion

    If you have a custom model for a view or partial view then instead of defining the model at the top of the view like this:

    @model MyCustomViewModel
    

    use an inherits statement and UmbracoViewPage like this:

    @inherits UmbracoViewPage<MyCustomViewModel>
    

    This will still give you access to your custom model properties via @Model.Name etc but will also setup the static helpers for things like UmbracoHelper that enable Umbraco.GetDictionaryValue to work...

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft