-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass parent block context during server side rendering #40714
Comments
Thank you for raising the issue and offering your help. I think you should be able to implement all the necessary changes in one PR inside the Gutenberg plugin. For REST API call you should be able to use existing hooks to pass additional params. The worst case scenario would be overridden the existing endpoint by reusing the current one with |
It would be great if we can pass parent block context during server side rendering. |
I have the same issue, can't access context during server side rendering from the block editor. Do you guys have a plan to add the built-in support? |
Yes, we definitely want to see this issue resolved! It looks like #34882 covers the same issue. |
Same here |
While this is not fixed, we can force the parameter on the child block: `
` |
Anything I or anyone else can do to help push this forward? |
bump ;) |
What problem does this address?
Currently, there is no way to use the
<ServerSideRender />
component with the block context. Only the rendered block attributes are sent (see). It means it is not possible to render a custom block in the editor accordingly to its context (unlike core blocks for instance). This does not allow good WYSIWYG in my opinion.I'm aware WordPress advises to render custom block using JavaScript. But with heavily dependent rendering on PHP (with all kind of data or complex logic) it can be hard to maintain.
What is your proposed solution?
<ServerSideRender />
could accept a new props (likeparentContext
) and pass it toapiFetch()
./wp/v2/block-rendered/
endpoint is registered and allow the new argumentparentContext
.WP_REST_Block_Renderer_Controller::get_item()
is usingrender_block()
to generate the response andrender_block()
is not able to handle parent context, it may required to change the behavior ofrender_block()
. Maybe with a new optional parameter ?I'd be glad to help with PRs, the only thing is I don't know how to split the code (i.e. one PR on Gutenberg for the
<ServerSideRender />
and an other on WordPress forget_item()
andrender_block()
?).The text was updated successfully, but these errors were encountered: