- This topic has 11 replies, 4 voices, and was last updated 2 years, 6 months ago by
Tom.
-
AuthorPosts
-
February 19, 2023 at 6:17 am #2538674
Taylor
I’m trying to use Gutenberg block templates – https://www.billerickson.net/gutenberg-block-templates/ to automatically insert a query loop block with a pre-defined layout.
However everytime the page loads the query loop, it presents the templates selector with examples and “start blank”. This causes it to not load my template inside the block.
How can I stop the template selector placeholder from loading and overriding the query loop template I set?
February 19, 2023 at 5:36 pm #2539183Fernando Customer Support
Hi Taylor,
Our solution for this would be to use GB Pro’s Local Pattern feature. Reference: https://docs.generateblocks.com/article/pattern-library-overview/
February 19, 2023 at 8:00 pm #2539261Taylor
Hi,
I don’t think Local pattern will work.
I am creating my own custom block and using the innerBlock component and setting the query loop as the template to load when you add it.
Similar to how the query loop automatically inserts a grid and container block inside when you add it to the page.
February 20, 2023 at 4:07 am #2539651David
StaffCustomer SupportHi there,
i am not sure on this, but is it possible to see your templates code ?
February 20, 2023 at 11:40 am #2540321Taylor
So my template code looks like this:
$template = [ [ 'generateblocks/query-loop', [ [ 'query' => ['post_type' => 'post'], 'lock' => ['remove' => true] ], ['generateblocks/grid', [ 'isDynamic' => true, 'blockVersion' => 3, 'isQueryLoop' => true, 'lock' => ['remove' => true], ], ['generateblocks/container', [ 'isGrid' => true, 'isQueryLoopItem' => true, 'blockVersion' => 3, 'lock' => ['remove' => true, 'move' => true], ], [ 'core/heading', [ 'content' => 'This is a title' ] ] ] ] ] ] ]; <div class="myCustomBlock"> <InnerBlocks template="<?= esc_attr( wp_json_encode( $template ) ); ?>" /> </div>
February 21, 2023 at 4:16 am #2541025David
StaffCustomer SupportI am not sure its possible to overcome that, as the template is literally inserting the block onto the page, so it will initiate the layout selector.
I assume nothing changes if you add more params to the
'query' => ['post_type' => 'post'],
arg ?February 21, 2023 at 4:30 am #2541042Taylor
No, adding params doesn’t change anything.
As a suggestion for a solution, could you perhaps add a key like
Layout-selector => false
Or even a hook to completely disable the layout selector popup globally as I start blank In most cases anyway.
February 21, 2023 at 5:36 am #2541101David
StaffCustomer SupportI have asked Tom and Jean to take a look, in case there is something that could be leveraged today, if not we’ll take a look at adding one.
February 21, 2023 at 5:49 am #2541116Taylor
Thank you for looking into it ♥️
February 22, 2023 at 8:18 pm #2543422Tom
Lead DeveloperLead DeveloperThat should technically work as our layout selector only displays if there are no inner blocks present.
Can you share your entire code (how you register the template as well) so I can try it on my dev server?
Thanks!
February 25, 2023 at 2:09 am #2546285Taylor
I’m using BlockStudio which supports InnerBlocks.
BlockStudio passes the template prop directly to the react InnerBlock component same as you would if you built the block using react.
My template markup is here – https://generatepress.com/forums/topic/query-loop-template/#post-2540321
Howevever, I found an alternative solution which didn’t require the use of the query loop innerBlock template
February 26, 2023 at 8:25 pm #2548035Tom
Lead DeveloperLead DeveloperStrange, it’s possible that using that method doesn’t allow our block to recognize any innerBlocks. We’ll look at a filter to skip the layout selector.
Glad you found an alternative solution!
-
AuthorPosts
- You must be logged in to reply to this topic.