MWDelaney / sage-acf-wp-blocks

Composer library for generating ACF Gutenberg blocks from templates. Intended for use with Roots/Sage (http://roots.io)
348 stars 65 forks source link

Render ACF Block inside a page template #25

Open ushka opened 5 years ago

ushka commented 5 years ago

Hello,

Thank you for the wonderful plugin.

Is there way to render an ACF Block you've created in a given page template (in my case a post template)?

I have developed a specific layout block that I want to be preloaded for all posts that have template = "three-col-layout".

Please advise if this is possible.

luukskeur commented 5 years ago

Hi @ushka since the Gutenberg editor is available inside the content you could simply display the_content.

If you would like to use some sort of block template (pre-defined block layout) you could create re-usable blocks. I think that is your best option since you want this block to be editable. Else you could simply create a custom ACF section outside of the editor.

tedw commented 4 years ago

@ushka I was able to render a block in my template with @include('blocks.my-custom-block') without any issues. I then cloned the block fields to that page’s field group in ACF.

This is actually the main reason I decided to use this plugin. Thanks to @MWDelaney for the great work!

markifornia commented 1 year ago

@tedw @luukskeur - I was able to do the same by assigning: views/footer-block.blade.php and assigning as a theme option then inserting @include('blocks.footer-block')in layouts/app.blade.php

All works well, the fields output. However - the block ID appears as empty when rendered

data-{{ $block['id'] }}  // block['id'] not putting ID

Is this possible or any theme configurations needed to get the ID to output?