Home Forums Newsletter Plugin Support Registration of custom blocks does not work

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #275839
    fasnacht.ch
    Participant

    Hello Together

    I am using the current version 7.2.7 and now wanted to add some custom blocks. The blocks are in a sub-folder of a plugin, the registration of the blocks is called from this plugin. I make the call as described in the documentation.

    However, the blocks are not registered properly, because none of the blocks are displayed. Only when I make the link directly to one of the blocks, this – but just this – is registered and displayed.

    Example:

    
    add_action('newsletter_register_blocks', 'my_newsletter_register_blocks');
    function my_newsletter_register_blocks() {
      $dir = __DIR__ . '/my-block';
      TNP_Composer::register_block($dir); 
    }
    

    displays nothing, while

    
    add_action('newsletter_register_blocks', 'my_newsletter_register_blocks');
    function my_newsletter_register_blocks() {
      $dir = __DIR__ . '/my-block/f-header';
      TNP_Composer::register_block($dir); 
    }
    

    displays the one block.

    It appears that the /my-block directory is not read properly. Instead of sub-folders, the actual block files are expected.

    In parallel, I also put my blocks into the “wp-content/extensions/newsletter/blocks/my-block” directory on a trial basis, but with exactly the same effect as described above.

    Am I doing something wrong?

    Looking forward to your appriciated support.

    Many thanks in advance.
    Brgds, Ivo

    #275926
    fasnacht.ch
    Participant

    Me again
    I have no clue why but I got it working in the “wp-content/extensions/newsletter/blocks/” directory. But I would prefer to have the blocks within my own plugin.
    Many thanks for your appriciated assistance.
    Brgds
    Ivo

    #276564
    Stefano
    Keymaster

    Hi, the register block call needs a directory that contains a single block where there is the block.php file. You can call the register block as many times as the blocks you need to register.
    There is a deprecated hook to register ALL blocks in a folder, it will be dismissed.

    #279490
    tengarisur
    Participant

    i’ve tried but it did’t worked for me.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.