Documentation / Tutorials / Awesome Enterprise

Creating Gutenberg Blocks in Awesome Enterprise

/ Awesome Enterprise / Creating Gutenberg Blocks in Awesome Enterprise

Please note this requires Awesome Enterprise version 1.3.5+ and the latest version of ACF PRO.

We now support ability to create basic Gutenberg blocks with help of Advanced Custom Fields plugin.

Basic Setup

  1. In awesome core create a module ‘gutenberg-blocks‘, if it is not already present. This is the module used to register all the Gutenberg blocks that will be available. Here is how you register the individual blocks.

    This will register a single block ‘Why choose use layout‘ in the Layout category. Check shortcode acf_blocks.register for the details and other parameters. This will only show the block in the backend.
  2.  If you need to add the form elements to this block you can create them using ACF. The only thing to remember is to select ‘Block’ in the rules and the block title for which these form fields will show up.
  3. Actually that’s it, this is all you need to do if your block service is ready.

Service Handler for the block

Assuming, you already know how to create a service, here is the code for the above service handler ‘g2aui.test.test_choose

The data from the block is passed to the service template using ‘data‘ variable which has all the meta_fields and their values. So, in this specific case title value is available using ‘[template.get data.title]‘ shortcode.

Following template variables are available to the service.

 

 

 

Categories
Most Popular

Leave a Reply

Your email address will not be published.