- This topic has 9 replies, 2 voices, and was last updated 1 year, 6 months ago by
Leo.
-
AuthorPosts
-
January 24, 2021 at 11:16 am #1631756
Dan
Hi, I’ve got a question regarding block patterns. Maybe not directly linked to Generate Press and GB, but since it’s my go-to theme and blocks plugin I wanted to raise this topic:
I would like to use block patterns as we used to use page templates, meaning:
1. Create a block pattern
2. Insert the block into the page
3. Edit the content of the blocks in the pattern (text and media changes mainly)
4. Use across a few pages
Now, what happens if you want to add a block to the pattern? I would like it to update across all the pages that have the pattern inserted. Is that possible?
Setting up a css class for the pattern can help with global styling the blocks in the pattern via a css file, but I am wondering about actually adding or moving blocks in the pattern and have that reflect on all the instances of the patterns inserted in the site.Example:
Think product pages for example, I have 50 products, each page created with the “Product pattern”, now I want to add a testimonials block to the pattern. Instead of going through 50 pages, I would just need to add it to the pattern and it will show up across all pages.Makes sense?
Thanks in advance for your guidance,
Dan
January 24, 2021 at 12:27 pm #1631808Leo
StaffCustomer SupportHi there,
Now, what happens if you want to add a block to the pattern? I would like it to update across all the pages that have the pattern inserted. Is that possible?
I could be wrong but I don’t believe this is possible within the Gutenberg editor yet.
You could check with WordPress’ support team and see if it’s possible or it could be a feature suggestion.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 24, 2021 at 12:34 pm #1631816Dan
Thanks Leo and Ying, would you think there is a way to create a ‘Block pattern template’ with a block element, where I could construct a series of blocks and then apply them to a specific page (via display rules). Then, if I change something inside the block element (one of the blocks, add or remove a block), that change would be applied to all the places where the block element is displayed?
Dan
January 24, 2021 at 12:37 pm #1631818Leo
StaffCustomer SupportBlock element should work like that by default no?
I thought you were talking about something like reuseable blocks.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 24, 2021 at 12:41 pm #1631819Dan
I would like to create a layout of blocks (like a pattern) but doesn’t have to be a ‘Gutenberg pattern’ per say.
Then I would be able to insert that pattern-of-blocks into a page. If I would need to further edit these blocks in the block element I could do so and the edit would reflect on all applied elements – I think that up to here we are good with block elements.Now, is there a way to call the block element into a page not with a hook but with a shortcode? or maybe with a php filter (I remember Tom menitoned a new filter he was introducing for creating page layouts), or even with an ACF select box where the user can select which layout he would like to display.
I don’t know where Ying’s comment disappeared, it’s not here.
Dan
January 24, 2021 at 12:46 pm #1631822Leo
StaffCustomer SupportNow, is there a way to call the block element into a page not with a hook but with a shortcode
I don’t believe there is a way to do that yet. Even with the local templates from GB pro, they don’t update automatically when you update them in the template file:
https://docs.generateblocks.com/article/template-library-overview/#local-templatesI believe the filter you are talking about is the
generate_do_template_part
and that’s for building post loop templates.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 24, 2021 at 12:50 pm #1631824Dan
So currently it will be on a per specific page basis to apply the block element? or creating a Custom post type? because the current location rules do not have a page template option.
January 24, 2021 at 12:53 pm #1631825Leo
StaffCustomer SupportThis should help:
https://generatepress.com/forums/topic/display-rule-for-a-specific-page-template/#post-885958Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 24, 2021 at 1:17 pm #1631843Dan
does this function tell element id to display in the hook location we set in the element on the ‘templates/jjma.php’ page template?
add_filter( 'generate_layout_element_display', function( $display, $element_id ) { if ( 123 === $element_id ) { if ( is_page_template( 'templates/jjma.php' ) ) { $display = true; } } return $display; }, 10, 2 );
January 24, 2021 at 6:07 pm #1631981Leo
StaffCustomer SupportThat one will work for layout elements.
This is the footer for hook elements:
https://docs.generatepress.com/article/generate_hook_element_display/The conditional tag and element ID is the same 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.