Handling dynamic blocks in Faust #1754
-
I'm currently reading through the docs and looking for suggestions/recommendations on the best approach here as we look at converting an ACF Block driven site over to NextJS. Ideally - I'd like to break away from using ACF blocks so we aren't supporting both PHP and React written components. For some some blocks, there are some pros/cons with having different HTML rendered content editors, but largely our blocks are simple enough that they can load just fine in the editor. We've had enough of our blocks change over the years that I'd rather stay with Dynamic Blocks so we aren't having to attempt recovery frequently when we make changes. I'm not sure if that is the best approach, but it seemed like a bigger pain when we are dealing with nearly 100 page websites. All of that said - Does Faust have a way to use the new |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @calebsmithdev . Regarding the new When you use the
On the other hand in the WordPress side you need to provide a In our plugin we do use the I suppose we could allow for a custom filter to run so that users can include their own renderCallbacks maybe something like: $block_args = apply_filters( 'faustwp_get_block_args', $block_args, $block_metadata ); // provide a render_callback for that particular block making it dynamic
if ( $block_metadata['name'] == 'create-block/block-a' ) {
$block_args['render_callback'] = function () {...}
} Does it make sense? It that what you are looking for? |
Beta Was this translation helpful? Give feedback.
Hey @calebsmithdev . Regarding the new
blockSet
command my understanding is that you can make a component dynamic by returning anull
Save function.When you use the
registerFaustBlock
function you can optionally pass a Save Function hereregisterFaustBlock(Block, {metadata, saveFn: () => null})
On the other hand in the WordPress side you need to provide a
renderCallback
function when registering a dynamic block.In our plugin we do use the
register_block_type
function in this section of the code:I suppose we could allow for a custom filter to run so that users can include their own renderCallbacks maybe something like: