I am using Block Preview in Umbraco 13.
Some of my properties are not rendering in the block preview in the back office.
They are being rendered in the standard Umbraco preview.
Before I go into more detail has anyone had anything similar?
I’ve had a few funnies, not all resolved. Which of your properties are not rendering?
I’m looping through the Block Grid Items in items.cshtml to index them:
// create an index for each item
var itemIndex = Model.ToList().IndexOf(item) + 1;
// pass the item index to the partial view
ViewData["itemIndex"] = itemIndex;
// create an index for each item of each type
var itemIndexOfType = Model.Where(x => x.Content.ContentType.Alias == item.Content.ContentType.Alias).ToList().IndexOf(item) + 1;
// pass the item index of type to the partial view
ViewData["indexOfType"] = itemIndexOfType;
then passing the value to my template that I sue for all block grid items:
// Retrieve the Item Index from ViewData in items.cshtml
var itemIndex = ViewData["itemIndex"] as int?;
// Retrieve the Index of Type from ViewData in items.cshtml
var itemIndexOfType = ViewData["indexOfType"] as int?;
and rendering @itemIndex and @itemIndexOfType where required.
It means I can automatically number them and works fine in the front end and Umbraco preview.
But they do not render in the back office.
OK so I took viewdata out of the equation:
var test = Model.ToList().IndexOf(item) + 1;
This display the Block Grid item number in the front end and Umbraco preview but not Block preview?