I'd love to know the answer to this one. With Umb7.7.3 and latest Vorto, in template: @Html.Raw(Model.GetVortoValue("content")) is putting out a big block of JSON. Content is a Vorto wrapped grid layout.
Thanks, but it's not a partial it's just a grid I'm trying to render in a view. I tried with and without @Html.Raw and the only difference was the formatting of the content sections, it renders JSON no matter what.
Anyway, just in case, I tried your suggested line and got a YSOD with "Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'Content'" So removed ".Content" but as expected VS complains "cannot implicitly convert type 'void' to 'object'.
I changed the property from "content" to "bodyText" in case I'd hit a ModelsBuilder reserved word. However, the results were just the same. Full page of unformatted JSON.
I see. You have a big misunderstanding here I think :)
When you use the grid editor, the value saved in your property is not HTML. What it's saved is a JSON object that contains all the information that represents the grid, like the rows, columns, theirs contents, type of editors used...
So if you try to display your property content it just shows that JSON string, which is exactly what you are seeing.
The grid editor used a partial view stored on ~/Views/Partials/Grid/
In that folder you have, and you can create, partial views which only goal is to get all that JSON object and 'translate' it into proper HTML. You have Bootstrap2.cshtml or Bootstrap3.cshtml.
To render the grid in the normal way you should use something like:
That helper with take the value of your bodyText and wil pass it to that partial view indicated by the last property, Bootstrap2 in this example.
In the case of Vorto, the value of the property will still be JSON but with the structure of a Vorto object, which contains the different values for the properties on each different language. And because this JSON doesn't represent the grid we can't use the GetGridHtml helper.
Instead we have to use the Bootstrap2 partial view manually, without helpers.
So we would take the value of the Vorto property like:
var gridObject = Model.Content.GetVortoValue("vortoGrid");
This will return the value of the Vorto object in regards to the current displayed language. You have to use the GetVortoValue extension for this.
Now that gridObject will contain a JSON string representing our grid for the language. That value has to be passed to the grid partial view to be rendered:
I was totally aware and happy that the Grid stored it's content as JSON. What I was having trouble with was discovering a syntax that extracted and displayed it with Vorto. This particular content is from an RTE in a Grid in a Vorto wrapper. So it now makes sense that you extract the Vorto on it's own first then run it through the Partial. I was under the impression that bit "just happened".
So, for anyone else coming by later, the final code that worked was:-
Note: with UmbracoViewPage you don't need ".Content" hence "Model.GetVortoValue(......". With UmbracoTemplatePage it needs to be "Model.Content.GetVortoValue(......."
Problem using Umbraco 7.3 with Vorto extension and Grid data type
Hi
I am not able to render the Grid, if the grid is wrapped in a Vorto (language extension) data type.
I am able to render the "content2", which is just the "grid data type":
but I am not able to render the "content", which is a Vorto wrapped "grid data type":
What am I doing wrong?
BTW: Is it possible to get/edit/copy the RAW data of a grid - just like it is possible to switch the rich text editor from html codes to text?
Best regards, Martin
Hi Martin,
Did you solve this? I am having the same problem.
Cheers
I'd love to know the answer to this one. With Umb7.7.3 and latest Vorto, in template:
@Html.Raw(Model.GetVortoValue("content"))
is putting out a big block of JSON. Content is a Vorto wrapped grid layout.Any advice appreciated.
--Craig
This should work.
Craig100, the grid data is indeed just JSON so it you display it with Html.Raw... well, you'll get a JSON string.
Martin, that line above is working for me. Are you getting any errors, or it's just blank?
Thanks, but it's not a partial it's just a grid I'm trying to render in a view. I tried with and without @Html.Raw and the only difference was the formatting of the content sections, it renders JSON no matter what.
Anyway, just in case, I tried your suggested line and got a YSOD with "Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'Content'" So removed ".Content" but as expected VS complains "cannot implicitly convert type 'void' to 'object'.
The View is just:-
I changed the property from "content" to "bodyText" in case I'd hit a ModelsBuilder reserved word. However, the results were just the same. Full page of unformatted JSON.
I see. You have a big misunderstanding here I think :)
When you use the grid editor, the value saved in your property is not HTML. What it's saved is a JSON object that contains all the information that represents the grid, like the rows, columns, theirs contents, type of editors used...
So if you try to display your property content it just shows that JSON string, which is exactly what you are seeing.
The grid editor used a partial view stored on ~/Views/Partials/Grid/ In that folder you have, and you can create, partial views which only goal is to get all that JSON object and 'translate' it into proper HTML. You have Bootstrap2.cshtml or Bootstrap3.cshtml.
To render the grid in the normal way you should use something like:
That helper with take the value of your bodyText and wil pass it to that partial view indicated by the last property, Bootstrap2 in this example.
In the case of Vorto, the value of the property will still be JSON but with the structure of a Vorto object, which contains the different values for the properties on each different language. And because this JSON doesn't represent the grid we can't use the GetGridHtml helper.
Instead we have to use the Bootstrap2 partial view manually, without helpers. So we would take the value of the Vorto property like:
This will return the value of the Vorto object in regards to the current displayed language. You have to use the GetVortoValue extension for this.
Now that gridObject will contain a JSON string representing our grid for the language. That value has to be passed to the grid partial view to be rendered:
I hope it makes sense.
Ah, NOW I see :)
Thanks for the clear explanation.
I was totally aware and happy that the Grid stored it's content as JSON. What I was having trouble with was discovering a syntax that extracted and displayed it with Vorto. This particular content is from an RTE in a Grid in a Vorto wrapper. So it now makes sense that you extract the Vorto on it's own first then run it through the Partial. I was under the impression that bit "just happened".
So, for anyone else coming by later, the final code that worked was:-
Note: with UmbracoViewPage you don't need ".Content" hence "Model.GetVortoValue(......". With UmbracoTemplatePage it needs to be "Model.Content.GetVortoValue(......."
Thanks again,
--Craig
Great. Martin, did you solve your issue? You were the one who create the post! :)
is working on a reply...