Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
413 stars 56 forks source link

Block context? #130

Closed danialvz closed 1 year ago

danialvz commented 1 year ago

Hi! This might be a dumb question, but I wasn't able to find any info on this. Is there a way to define block context using the Block class definition?

Thanks

Log1x commented 1 year ago

I haven't looked into block contexts yet (nor do I fully understand them) but it looks like I'm missing 2 new variables added to the block render callback.

https://www.advancedcustomfields.com/resources/acf_register_block_type/#registering-a-block-with-callback

$wp_block and $context are currently not getting passed.

I'll read into it more unless you have any input on how to proceed.

Log1x commented 1 year ago

I added the missing call for $context in the block render callback but I'm only seeing it return output like:

Screenshot

What were you trying to achieve exactly? Maybe you can pass a specific context using $supports or something? Can you give me an example of a use-case for this so I can better understand?

I'm thinking just needing $context available is not all that you needed.

pat-flew commented 1 year ago

Hey log1x, not sure if related, but I was looking for something that sounds a bit similar to OP

I need to supply uses_context value when registering a new block, so that when the block placed within a query loop, it can retrieve the queryId value created by the query loop block. It is ultimately for a query filter block that will be exposed to the user.

I've created a pull request for the update #153