Support

Account

Home Forums Gutenberg InnerBlocks use multiple & allowed_blocks

Solving

InnerBlocks use multiple & allowed_blocks

  • Hey,

    my first post here. 🖖

    1. Tried to use InnerBlocks more than once in a block and saw later, in the docs, this isn’t possible. Any plans on implementing it in a later release?
    2. InnerBlocks seem perfect to edit directly in the preview column. It seems as if it is currently not possible to limit the allowed blocks per block. We have to allow them globally to use them in a block, right?

    Alex

  • Hi,
    do you have find solution ? I try also

  • I have spend multiple hours trying to figure a way around this and to my likings I haven’t found an ideal solution. The problem is Innerblocks isn’t really an ACF function but a WordPress function.

    Although I don’t really understand your question the closest I’ve come to a workable pagebuilder with container+columns is this way:

    This is a content container block

    $allowed_blocks = [ 'acf/contentpartial' ];
    <div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?>">
        <?php if($container == 'container-fluid'): echo '<div class="container">';  endif; ?>
            <div class="row">
                    <InnerBlocks 
                    allowedBlocks="<?php echo esc_attr( wp_json_encode( $allowed_blocks ) ); ?>"
                    />
    
            </div>
        <?php if($container == 'container-fluid'): echo '</div>'; endif; ?>
    </div>

    In which you load the partial:

    $allowed_blocks = [ 'core/heading', 'core/paragraph','core/list', 'core/button', 'core/image', 'core/shortcode', 'gravityforms/form'];
    $col = get_field('col_grootte');
    ?>
    <div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?> <?php echo $col; ?> pt-<?php the_field('ruimte_boven'); ?> pb-<?php the_field('ruimte_onder'); ?> editor-reset">
        
        <div class="content-block">
    
            <InnerBlocks allowedBlocks="<?php echo esc_attr( wp_json_encode( $allowed_blocks ) ); ?>" />
    
        </div> 
    
    </div>

    This only problem is that you have to manually select the column size. It can’t be col-6 whenever there are 2 partials automatically.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.