Can a Block List be added as a block on a Block Grid?
Hi,
we have a requirement for a 'Timeline' which we plan to implement as a block list with a 'TimelineEntry' element type.
We then want to be able to add this 'Timeline' as a block within a Block Grid so that the timeline can be placed in any row / column in the Block Grid.
Is this possible?
We are looking to implement in Umbraco 10 and Umbraco 13.
However I am not sure how to render the blocklist html in the /blockgrid/Componenents/Timeline.cshtml partial view.
I have tried:
@Html.GetBlockListHtml(Model, "timeline")
But am getting the error:
*'IHtmlHelper<dynamic>' has no applicable method named 'GetBlockListHtml' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.*
I am not sure what I need to declare as the model in the partial view. Can anyone advise?
Then in the partial view for the block that is added to the BlockList:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem>;
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
var content = (ContentModels.TimelineItem)Model.Content;
}
@*Output the value of field with alias 'title' from the Element Type selected as Content section*@
<h1>@content.Value("title")</h1>
<h3>@content.Value("description")</h3>
Can a Block List be added as a block on a Block Grid?
Hi,
we have a requirement for a 'Timeline' which we plan to implement as a block list with a 'TimelineEntry' element type.
We then want to be able to add this 'Timeline' as a block within a Block Grid so that the timeline can be placed in any row / column in the Block Grid.
Is this possible?
We are looking to implement in Umbraco 10 and Umbraco 13.
thanks,
Nick
Yes, you can add blocklists to a blockgrid
Thanks Huw, to achieve this would the process be to:
1) create an element type that had the block list property editor on it and then 2) add that element type as a block on the block grid?
Yes, that is correct
Thanks, I have created the following:
TimelineItem (Element Type)
Timeline (Block List Property Editor) and added the TimelineItem as a block type
Timeline (Element Type) and added the Timeline block list property editor to it with an alias of timelineList
Then I have then created a BlockGrid property editor (and added the Timeline element type to the Blocks).
I have the created a document type with template called GridPage and added the BlockGrid property editor to it with an alias of "grid".
Then added the following code to the GridPage template:
I then had to add a partial view at:
/Views/partials/blockgrid/Components/Timeline.cshtml
However I am not sure how to render the blocklist html in the /blockgrid/Componenents/Timeline.cshtml partial view.
I have tried:
But am getting the error:
I am not sure what I need to declare as the model in the partial view. Can anyone advise?
Hi Nick,
The example below is for just a simple image but should give you an idea
Thanks Huw, I now have the following code working...
In the partial view for the block that will be added to the grid:
Then in the partial view for the block that is added to the BlockList:
Glad you have it sorted
Glad you have it sorted
is working on a reply...