Setting instance properties on global blocks

Vote:
 

Hi there,

I am curious what the best way to approach being able to set instance properties on global blocks.

For example, I have a global blocks that render two columns and I would like to be able to set whether the columns are rendered Left-Right or Right-Left for each individual instance of the block. My goal would be to leverage global blocks while not having to create separate versions with the same content just because I want to adjust the layout on specific pages.  

#260080
Aug 04, 2021 19:25
Vote:
 

So, you have created a block of type "block type x", and you are using that single block on multiple places, but you want to render the block differently on different places? 

What/who controls how the block should be rendered?  If the editor should control it, it could be a setting on e.g. the page where the block is added. Or, it can be controlled by what page type (or any content type) that renders the block. You could even create a new block type that just contains this setting, and you add your block to that one.
Either way you need to pass this setting when the block is rendered.

Let me know if you need help with how to pass the setting from e.g. the page to a block that is rendered in a content area.

#260139
Aug 05, 2021 9:15
Vote:
 

It sounds like you want to implement the display options for these layouts https://world.optimizely.com/documentation/developer-guides/CMS/rendering/display-options/ .

These are designed to be able to apply different display layouts to a block without changing the block pages. I would create display options for this 2 layout types, then you can either render different layouts or just adapt layout based on the passed in tag. If you need to control them on a individual block lever I have a solutiion for that https://world.optimizely.com/blogs/scott-reed/dates/2018/4/controlling-episerver-display-options-via-a-custom-attribute/ 

#260140
Aug 05, 2021 9:16
Vote:
 

Ah, yes, dispaly options! Forgot about those, rarely use it. But in this case it may be a good fit.

#260142
Aug 05, 2021 9:38
Scott Reed - Aug 05, 2021 9:53
Yes. I think they are like the marmite of CMS features, you either love them or hate them. I used to build all my responsive base build grids around them like Alloy does for maximum flexibility, it was a bit of an effort but once the framework is there it's pretty groovy
Vote:
 

Thanks for the responses! Display options looks like exactly what I'm looking for and I believe are using for some blocks already so will dig in there.

#260156
Aug 05, 2021 16:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.