Setting instance properties on global blocks


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.  

Aug 04, 2021 19:25

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.

Aug 05, 2021 9:15

It sounds like you want to implement the display options for these layouts .

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 

Aug 05, 2021 9:16

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

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

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.

Aug 05, 2021 16:59
* 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.