Copied to clipboard

Flag this post as spam?

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


  • Bryna 74 posts 260 karma points
    Jan 16, 2019 @ 19:09
    Bryna
    0

    Umbraco 8 Issues

    Umbraco version 8.0.0-alpha.58.1580

    I have a few sites I am looking at putting into Umbraco[over 1K pages]. I did about 1 weeks worth of work in 7.12 before finding that Umbraco 8 is a migration versus an upgrade, so I obtained a alpha build from nuget, and was able to get it installed and running thanks to some prior posts.

    I tried all the code combinations listed at https://our.umbraco.com/Documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Grid-Layout/Render-Grid-In-Template#render-grid-in-template .

    What am I missing?

    enter image description here

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2019 @ 22:24
    Jan Skovgaard
    100

    Hi Bryna

    I have not yet had the chance to play around with rendering content in V8 - But if I remember correctly you will no longer be able to use .GetPropertyValue() - So instead you should be able to do either

    @Html.Raw(Model.Content)
    

    or

    @Html.Raw(Model.Value("content"))
    

    Does this help?

    /Jan

  • Bryna 74 posts 260 karma points
    Jan 22, 2019 @ 18:49
    Bryna
    0

    It gives me a bunch of json formatted text. Oooh.... Now I see. It appears that if someone doesn't put any text in the actual content the default behaviour is showing json content for the rich text editor.

    Thank you Jan.

  • Chris Evans 137 posts 353 karma points c-trib
    Jan 29, 2019 @ 03:11
    Chris Evans
    1

    Hey Bryna,

    I think there's a few issues here compounding each other.

    First: In your example, the property has an alias of "content". This means that if you reference Model.Content in a template that uses ModelsBuilder (which will probably be enabled by default), you're actually talking to the strongly typed property called Content - which will be of type JToken because it's a Grid layout.

    These properties are automatically generated from the alias names (so if you had a textstring property with an alias of "myNiceField" you'd get a strongly typed property called MyNiceField, which would be a string).

    As such it's usually good to avoid calling properties "content" because it can be confusing.

    You can tell if you're using the ModelsBuilder if your view has something like this at the top:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Home>
    @using ContentModels = Umbraco.Web.PublishedModels;
    

    Second: Model.Content.GetPropertyValue(alias) is the Umbraco 7 API syntax. This has changed in Umbraco 8 to be like this:

    Model.Value(alias)
    

    Model.Content was the IPublishedContent object exposed to the View in Umbraco 7, whereas in 8 by default it is referenced just with the name Model (see UmbracoTemplatePage vs. UmbracoViewPage).

    Strongly typed properties are also possible by adding

    Model.Content.GetPropertyValue<int>(alias)  //umbraco 7
    Model.Value<int>(alias) //umbraco 8
    

    Third: Because you're using a Grid layout, you don't want to render the actual value stored against the property: this is the JSON structure that represents the grid rows and columns, and which editors have been added to it, as well as the content values for each editor.

    Instead, you need to call the GetGridHtml method of the Html helper, like this:

    @Html.GetGridHtml(Model.Content, alias) //umbraco 7
    @Html.GetGridHtml(Model, alias) //umbraco 8
    

    Note you don't need to wrap it in Html.Raw as the method returns an MvcHtmlString, which the view will properly render on its own.

    The html structure for the grid that renders around your content, and also for each different editor type is controlled inside the Views/Partials/Grid folder. By default it outputs a generic Bootstrap 3 layout but you can tweak this as required by editing the view contents.

    Hope this all helps!

Please Sign in or register to post replies

Write your reply to:

Draft