Nested blocks / custom HTML
-
Some of the core Gutenberg blocks allow nesting other blocks within them, like
layout
Would it be possible to do this in Block Lab maybe by having a ‘Custom HTML’ field type that functions like the core Gutenberg one?
Ultimately if one could add custom blocks they’ve made or core Gutenberg ones, within others blocks they’re making that would open up a whole bunch of possibilities.
For e.g. I’ve made a slightly enhanced accordion block with a badge in the heading. The template file’s contents look like this, look at the comment in the accordion text:
<div class="panel panel-default"> <h5 class="panel-heading"> <a class="" role="button" data-toggle="collapse" href="#<?php block_field( 'id' ); ?>" aria-expanded="true" aria-controls="collapse-3"> <?php block_field( 'title' ); ?> <span class="badge pull-right"><?php block_field( 'badge' ); ?></span> </a> </h5> <div id="<?php block_field( 'id' ); ?>" class="collapse in" aria-expanded="true" style=""> <p class="panel-body"> <?php block_field( 'content-text' ); ?> <!-- this is a textarea field type --> <!-- In editing mode could we click into it and have a '+' to add another custom block like gutenberg does? --> </p> </div> </div>
In your recent blog post you’ve achieved something similar with gravity forms by using
gravity_form( $form_id , false, false, false, '', true, 12 );
in the template and referencing the form ID, this was possible because gravity form allows embedding by calling a PHP function and also it feels kind of hardcoding one instance of the form block into our custom block.
Would it be possible to have a field type that allows this in Block Lab?
- The topic ‘Nested blocks / custom HTML’ is closed to new replies.