Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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
Does this help?
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.
I think there's a few issues here compounding each other.
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:
@using ContentModels = Umbraco.Web.PublishedModels;
Model.Content.GetPropertyValue(alias) is the Umbraco 7 API syntax. This has changed in Umbraco 8 to be like this:
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
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!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted