Copied to clipboard

Flag this post as spam?

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


  • Henrik Vincent 122 posts 616 karma points
    Mar 08, 2019 @ 13:50
    Henrik Vincent
    0

    Problems with v7 macros and views

    Hi guys

    I just started movinga site from v7 to v8, but keep running into some trouble.

    I keep getting this error for most of my views and macros.

    'IPublishedContent' does not contain a definition for 'GetPropertyValue'

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Umbraco.Web
    @{
      if (Model.Content.HasValue("canonical")){
        var node = Model.Content.GetPropertyValue<int>("canonical");
        <link rel="canonical" href='@node.Url'>
      }else{
        <link rel="canonical" href='@Model.Content.Url'>
      }
    }
    

    What changed, that makes these definitions not work?

    Hope you guys can help me out.

    Best

    Henrik

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Mar 08, 2019 @ 14:20
    Sebastiaan Janssen
    100

    Try Model.Content.Value<int>("canonical"); instead. :)

  • Henrik Vincent 122 posts 616 karma points
    Mar 08, 2019 @ 14:27
    Henrik Vincent
    0

    Thanks Sebastiaan!

    That worked.

    Makes sense now. Figured out earlier that @Umbraco.Field was also changed to @Model.Value.

    Are these changes new to v8?

    Best

    Henrik

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Mar 08, 2019 @ 14:54
    Sebastiaan Janssen
    1

    They are! Some further reading: https://shazwazza.com/media/1032/uduf-2019.pdf

  • Henrik Vincent 122 posts 616 karma points
    Mar 10, 2019 @ 07:19
    Henrik Vincent
    0

    Awesome thanks! 😊

Please Sign in or register to post replies

Write your reply to:

Draft