The psuedo code below sits in a Partial View that supplies the Main Navigation to a site. What needs to take the place of the ??????? to get it to work? I'd like to add the Model of each item automatically but don't know how.
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<IPublishedContent>
var site = Model.Root();
var siteSettings = site.Siblings().FirstOrDefault(x => x.ContentType.Alias == "siteWideSettings");
var menuItems = siteSettings.Value<IEnumerable<IPublishedContent>>("megaMenu");
foreach (var item in menuItems) {
if (item.ContentType.Alias == "sectionHeader") {
@await Html.GetBlockGridHtmlAsync(???????,"subNavLinks")
}
}
"ModelBindingException: Cannot bind source type Umbraco.Cms.Core.Models.Blocks.BlockGridItem2[[Umbraco.Cms.Web.Common.PublishedModels.Columns66, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Umbraco.Cms.Core.Models.PublishedContent.IPublishedElement, Umbraco.Core, Version=11.1.0.0, Culture=neutral, PublicKeyToken=null]] to model type Umbraco.Cms.Core.Models.Blocks.BlockGridItem2[[Umbraco.Cms.Web.Common.PublishedModels.Columns66, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Umbraco.Cms.Web.Common.PublishedModels.BlockSettings, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]."
Columns66 being my 2 column layout.
As the partial is part of a Mega Menu, I was wondering if the blockGrid there is affecting the blockGrid in the main page as well. I mean, can you have more than one blockGrid in a page and can they use the same default template?
As the partial is part of a Mega Menu, I was wondering if the
blockGrid there is affecting the blockGrid in the main page as well. I
mean, can you have more than one blockGrid in a page and can they use
the same default template?
I haven't attempted using more than one on a page, but I am using some nested blockgrids on my site so assume you should be able to have more than one blockgrid, I don't know if they can both use the same default template as I use individual templates for most of my blockgrids/items
Rendering BlockGrid in a partial
V11.1.0
The psuedo code below sits in a Partial View that supplies the Main Navigation to a site. What needs to take the place of the ??????? to get it to work? I'd like to add the Model of each item automatically but don't know how.
Any advice would be appreciated.
The ??????? needs to be replaced with a BlockGridModel object
e.g.
Thanks for that but......
Allowing it to use the default blockGrid template, as all my other blockGrids do, it blows up. So using:-
produces:-
"ModelBindingException: Cannot bind source type Umbraco.Cms.Core.Models.Blocks.BlockGridItem
2[[Umbraco.Cms.Web.Common.PublishedModels.Columns66, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Umbraco.Cms.Core.Models.PublishedContent.IPublishedElement, Umbraco.Core, Version=11.1.0.0, Culture=neutral, PublicKeyToken=null]] to model type Umbraco.Cms.Core.Models.Blocks.BlockGridItem
2[[Umbraco.Cms.Web.Common.PublishedModels.Columns66, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Umbraco.Cms.Web.Common.PublishedModels.BlockSettings, Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]."Columns66 being my 2 column layout.
As the partial is part of a Mega Menu, I was wondering if the blockGrid there is affecting the blockGrid in the main page as well. I mean, can you have more than one blockGrid in a page and can they use the same default template?
I haven't attempted using more than one on a page, but I am using some nested blockgrids on my site so assume you should be able to have more than one blockgrid, I don't know if they can both use the same default template as I use individual templates for most of my blockgrids/items
is working on a reply...