Add extension to add block to block list model #14120
Replies: 3 comments 1 reply
-
The Allowing developers to modify the model could therefore lead to unexpected results. Eg. with your example, if But adding some constructor overloads would be a good idea. For instance a constructor that takes an |
Beta Was this translation helpful? Give feedback.
-
I added an extension method:
And then in view I have this:
|
Beta Was this translation helpful? Give feedback.
-
How common a use case is this? Not sure such extensions belong in the CMS, if it is a rare use case |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Based on Umbraco v10.4.0 I had a use-case with a block list used in a sidebar and further a global block list (single block mode), where I wanted this the be added to block list model on specific page types.
I could add in the block list on these page type, but it would be tedious to copy/paste this to each block list and since this block always needed same content, I wanted to add this globally.
I found this works:
but maybe we should have some additional extension methods on
BlockListModel
? eg.Add()
,Prepend()
,Append()
,Insert()
,Remove()
. The ctor takesIList<BlockListItem>
Beta Was this translation helpful? Give feedback.
All reactions