Copied to clipboard

Flag this post as spam?

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


  • George Phillipson 108 posts 287 karma points
    Mar 01, 2019 @ 11:49
    George Phillipson
    0

    SurfaceController RenderMvcControllers documenation

    Hi Daft question is there any documentation for surface and RenderMvcControllers for Umbraco 8.

    I cannot seem to get getpropertyvalue anymore

    Thanks George

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 01, 2019 @ 12:20
    Sebastiaan Janssen
    0

    Try GetValue instead if you're working from Services, otherwise for IPublishedContent items, it's just .Value.

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 01, 2019 @ 12:51
    Bjarne Fyrstenborg
    0

    Hi George

    I think these extension methods have been simplified in v8, so instead of having Umbraco.Field(), .GetProperty, GetPropertyValue, now there is an extension method .Value() on IPublishedContent, e.g.

    var node = Umbraco.AssignedContentItem;
    
    var myProperty1 = node.Value("myProperty");
    var myProperty2 = node.Value<string>("myProperty");
    var myProperty3 = node.Value<string>("myProperty", "en-US");
    

    /Bjarne

  • George Phillipson 108 posts 287 karma points
    Mar 01, 2019 @ 13:06
    George Phillipson
    0

    Hi Bjarne

    That seems right, but it seems you no longer need to add string etc as I added

     HtmlString text = rte.Value<HtmlString>("testRte", defaultValue: new HtmlString("Im default"));
    

    The above flags up 'type argument specification is redundant'

    Just need to figure out macros now :)

    As macros now return the following text on the webpage: Umbraco.Web.Macros.MacroContent

    George

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Mar 01, 2019 @ 13:28
    Bjarne Fyrstenborg
    0

    It depends on your property and which type you cast the property value to.

    Rich text editor return IHtmlString, but if you are using ModelsBuilder the strongly typed models are already generated the properties using the correct types, at least for the core property editors or where a property value converter is available, otherwise the default type is of type object.

    var site = Umbraco.AssignedContentItem.AncestorOrSelf(1);
    var contactPage = site.FirstChild<Contact>();
    
    var intro = contactPage.ContactIntro;
    
  • George Phillipson 108 posts 287 karma points
    Mar 01, 2019 @ 13:35
    George Phillipson
    0

    Hi Bjarne

    Thanks, this change to version 8 reminds me of when Microsoft went from classic asp to ASP.NET, big changes

    George

Please Sign in or register to post replies

Write your reply to:

Draft