- This topic has 15 replies, 4 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
December 31, 2021 at 2:58 am #2064633
Tobias
Hi,
I was not sure if I should reply on this thread: https://generatepress.com/forums/topic/reusable-blocks/ or create a new one. I decided to do the last option.
About reusable blocks: I love the feature in WordPress, but I am using it a bit different. So now I wonder if there is a real solution for the problem I try to solve with reusable blocks.
How do I use it now?
I have created a product box for product review pages. I add a reusable block (that I made earlier) and add it to the page. Then I choose ‘Convert to regular block’.
Then I edit the content.So I never use reusable blocks for what it is meant: centrally manage identical content that is placed on different pages.
Now my question is:
Is there a way I can add this product box (or any other block created in generateblocks) to a page, be able to centrally manage the looks of that block (such as the padding, margin, colors etcetc) but being able to change the content (text, image, and button link etc).So shortly said:
– I would like to centrally manage the design of a specific block that I use on multiple pages.
– I would like to be able to manage the content in that block on the page level.How would I be able to do this?
December 31, 2021 at 7:50 am #2064954Tobias
And by ‘block’ I mean a combination of blocks that I have placed in a container block. If I need to clarify my question I’d be happy to do so.
December 31, 2021 at 9:39 am #2065035David
StaffCustomer SupportHi there,
you can do it with GenerateBlocks Pro Global Styles:
January 6, 2022 at 2:22 am #2070882Tobias
Hi David,
The Global style feature is a great feature! Thanks for that. I feel like I am a lot closer to the solution. But:
My ‘product box’ consists of multiple containers. So:
– a main container
– a container with a title
– a container with an image
– a container with a text
– a container with a star rating
– a container with a buttonThe only option I see is:
- Giving all of the containers a Global Style name
- Then create a Local Template and give the different containers the global styles I created
- And from there always use the Local template I created if I want to use a ‘product box’
Is this the best practice? Or is there a better and easier way?
The ‘problem’ is/might be that this way you I will get a lot of Global styles. But maybe I just have to name all styles like this to keep a good overview:
-product-box
-product-box-titel
-product-box-header
-product-box-image
-product-box-button
etc.Is that how that works best?
January 6, 2022 at 3:37 am #2070926Elvis
Natively I would say this is what Block Patterns are used for. In comparison to Reusable Blocks, Patterns inherit styles but not content. However GB global styles allow for more control from the side of the developer.
I would just want to mention two things about global styles.
– One: it looks like global styles are a preparation for custom block/pattern building in generate blocks. Am I wrong?
– Currently the functionality is almost all there, only the usability is a bit difficult. It would be great from that perspective if the global styles could be accessible from a menu, or block selection in gutenberg, so that it is easy for clients to access them. Are there any plans to do something like this?I am considering to use this approach instead of a native one to have more control over what client can do with gutenberg https://www.billerickson.net/innerblocks-with-acf-blocks/ but then realised global styles could do this. The only advantage I can now see in acf approach is that these can then be accessed as other blocks so it becomes easier for clients to use them. But If I could do all this with GP blocks that would be preferable.
January 6, 2022 at 5:32 am #2070999David
StaffCustomer SupportTobias – yes that is exactly how you would use the Global Styles with a GB Local Template.
Hi Elvis,
For your requirement you would work the same way that Tobias is.
First create GB Global Styles for each of the various blocks you require.
Then create a GB Local Template, add your blocks and apply the global styles to them. You can think of this as the a GB Pattern ( on steroids ).
Then the end user would add a GB Local Template ( from the menu ) to their post instead of adding a single block.If in the future a style refresh is required then you edit the Global Styles, any blocks using those styles whether they be in the GB Local Template library or added to the editor will reflect those changes.
January 6, 2022 at 6:11 am #2071022Tobias
I will mark this support topic as solved, as this is a clear and good solution. Thanks for the help.
January 6, 2022 at 6:28 am #2071035David
StaffCustomer SupportGlad to be of help!
January 6, 2022 at 7:37 am #2071122Elvis
Tnx David
January 6, 2022 at 8:17 am #2071320David
StaffCustomer SupportYou’re welcome too
March 1, 2022 at 1:50 pm #2138605Elvis
Just to say I just started playing with Local Templates … OMFG this is briliant.
March 2, 2022 at 3:36 am #2139156David
StaffCustomer SupportAwesome – glad to hear that
March 2, 2022 at 1:07 pm #2139993Elvis
Hi David,
this is perfect, I can really build a an atomic design system like this.One thing that bugs me though.
I would love to hide the gb blocks controld from other users on the site, the team is quite big, and includes people of various skillsets, and so many options in GB will be overwhelming.
As mentioned here I can set my defaults wich is great, but there can still be overriden locally.
If I allow only some core blocks for editors I am half-way there, they can only use the blocks I have placed on the page or the core blocks, but they can still mess up the padding margin etc.
Core blocks can have their controls removed via theme.json like this https://github.com/thisbit/gutenberg-docs-for-humans/blob/main/Theme.json.md
Can I use theme.json to kill the GB features once I set my defaults fo GB blocks? Or is there another way to do this?
Too much power for casual editors.
Thanks
March 3, 2022 at 8:14 pm #2141647Tom
Lead DeveloperLead DeveloperHi there,
It’s not possible now without some pretty advanced coding, but it’s a feature we will be introducing to GB Pro this year 🙂
Thanks!
March 4, 2022 at 2:46 am #2141892Elvis
Thanks for your reply Tom,
this a very important feature for GB if it is meant to be used with clients, because all the great many features (settings) exposed to the dev, become a problem for clients and enforcing the styleguide for the site. So great news that you will be introducing it this year. This is realy great news.
I have tried to use both theme.json for GB, and tried to unregister blocks style, and while I can use these methods with core/blocks it does not work with generateblocks/blocks.
While waiting for the native feature to arrive, I wish to share how I handle this now.
I am loading a css file in the editor on the post type condition so that the blocks settings panels are available (visible) only in, Global styles post type, Local Templates post type, and in Elements post type. The admin has them available in all post types (if local overrides are needed), and I can allow different groups of users (some native, some custom) to access the elements for example (not probable, but possible).
I am leaving the Advanced pannel open to all, and I have added toggles there to enable variations on global styles to be available via classes. So editor can now easily control the size of button, or vertical spacing of a custom built local template via toggle.
This is the way to control the design system so that global styling is a first class citizen. And to control who can access what. Also allowed_blocks method, limits available blocks to the editors group to some basic core ones, and everything else (built with GB), various layouts sections, and more complex blocks/components, are available as local templates only.
I am now testing this solution and so far it seems it works quite nicely. 🙂
Best -
AuthorPosts
- You must be logged in to reply to this topic.