Each partial view is named to match the blockAlias.
From within the partial view, I would like to access the settings for the blockItem. I am not sure how to do this.
I can access the node that contains the blockItem with Umbraco.AssignedContentItem
However, I cannot find the code that will allow me to get the block list item of which this element is the content. That should allow me to get the settings element. Any thoughts?
How to get Block Item Settings in a Partial View that is Typed to the Block Item Content?
I loop through a block list like this (simplified, but you get the idea):
Each partial view is named to match the blockAlias.
From within the partial view, I would like to access the settings for the blockItem. I am not sure how to do this.
I can access the node that contains the blockItem with
Umbraco.AssignedContentItem
However, I cannot find the code that will allow me to get the block list item of which this element is the content. That should allow me to get the settings element. Any thoughts?
My usual setup is something like this, where you call a "base" block list partial view containing
and then in the partial view for each element you can start the file with (replacing TContent and TSettings with your content and settings models)
Which then enables you to access the content and settings with
Thanks Matthew- that works great.
One question: how do you get values from the
Umbraco.AssignedContentItem
(i.e. from the node that contains the block list)?Previously this was available as the model was an
ipublishedelement
.Matthew had this reply to my last question:
If you instead change from
@model BlockListItem
..... to@inherits UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem<TDocument, TSettings>>
Then you can access the current page with something like
@UmbracoContext.PublishedRequest.PublishedContent
NB:
AssignedContentItem
isn't always the requested pageMatthew said this (elsewhere):
If you instead change from
@model BlockListItem
..... to@inherits UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem<TDocument, TSettings>>
Then you can access the current page with something like
@UmbracoContext.PublishedRequest.PublishedContent
NB:
AssignedContentItem
isn't always the requested pageis working on a reply...