You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exploring theme blocks, I discovered a limitation that I believe could be improved. Currently, we define presets within a block (for example, different types of group layouts like Column, Row etc.). It would be great if, when creating new sections or nesting blocks, we could simply reference these predefined presets instead of duplicating the settings.
This approach would allow us to store presets in a single block file and then reference them elsewhere—reducing code repetition and simplifying maintenance.
Referencing the presets in other Blocks or Sections
// file sections/feature.liquid// or a block: blocks/someBlock.liquid
{
"name": "Feature Section",
"settings": [
// Regular section settings
],
"presets": [
{
"name": "Feature Section",
"settings": {
// Section settings
},
"blocks": [
{
"type": "group",
"preset": "Row",
"settings": {
"gap": 12// This would override the setting defined in the preset for this section, but keep the rest of the preset settings the same// or don't include settings to use only the preset settings
}
}
]
}
]
}
If a preset (for example, the "Row" preset in the Group block) includes blocks, those blocks are used if the section doesn't provide its own blocks array. If the section does specify blocks, they completely replace the ones from the preset. Similarly, any settings defined in the section that conflict with the preset's settings will override the preset values, but non-conflicting settings remain unchanged. This lets you fine tune presets without duplicating code.
Implementing this would not only eliminate repetitive code but also some what centralise settings management, making updates and maintenance easier. Or if anyone has a cleaner and better idea? My idea is to give us developers the same access merchants has to presets in the editor.
I saw this discussion about saving entire schema settings in a totally separate json file, but I believe this tackles another issue. Tho I would love to see something like a separate json file to centralise schema settings to not be repeated in a neat way (if possible).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When exploring theme blocks, I discovered a limitation that I believe could be improved. Currently, we define presets within a block (for example, different types of group layouts like Column, Row etc.). It would be great if, when creating new sections or nesting blocks, we could simply reference these predefined presets instead of duplicating the settings.
This approach would allow us to store presets in a single block file and then reference them elsewhere—reducing code repetition and simplifying maintenance.
Block Schema Example
Referencing the presets in other Blocks or Sections
If a preset (for example, the "Row" preset in the Group block) includes blocks, those blocks are used if the section doesn't provide its own blocks array. If the section does specify blocks, they completely replace the ones from the preset. Similarly, any settings defined in the section that conflict with the preset's settings will override the preset values, but non-conflicting settings remain unchanged. This lets you fine tune presets without duplicating code.
Implementing this would not only eliminate repetitive code but also some what centralise settings management, making updates and maintenance easier. Or if anyone has a cleaner and better idea? My idea is to give us developers the same access merchants has to presets in the editor.
I saw this discussion about saving entire schema settings in a totally separate json file, but I believe this tackles another issue. Tho I would love to see something like a separate json file to centralise schema settings to not be repeated in a neat way (if possible).
Beta Was this translation helpful? Give feedback.
All reactions