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 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
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.
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:
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
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:
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.
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?
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 eitheror
Does this help?
/Jan
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.
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:
Second: 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
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:
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...