Closed bobbingwide closed 2 years ago
See #12 for a summary of required blocks.
While developing the Fields block I discovered that the version of ServerSideRender
that passes the post_id
to the REST API is in wp.editor
; not wp.components
as currently documented.
The code was changed in PR 8720, but there don't appear to be any deprecation notices. Each block developed so far should be updated.
Perhaps there should be a summary of where to import components from.
If you register a Server Side Rendered block with
supports: {
customClassName: true,
className: true }
then you have to ensure that these fields are registered in the PHP.
If you don't then you'll get Error loading block: Invalid parameter(s): attributes
when you attempt to complete the Additional CSS Class field.
The problem only occurs in the editor. When the post is displayed there isn't any checking.
Need to confirm what in the client end sets customClassName
.
Also, it's not a good idea to set supports.html: true for this type of block.
Closing this. I've developed a number of blocks that use Server Side Rendering. I experienced quite a few problems along the way. But I reckon I've got it sussed now. See https://github.com/bobbingwide/oik-bob-bing-wide/issues/42
Gutenberg provides a mechanism called
ServerSideRender
which allows a block to be rendered by the server. It’s intended for legacy code, which is exactly what some of the shortcodes are. We should experiment with this solution to attempt to render the real block that’s displayed for a subset of shortcodes. Starting with:For some logic the server side rendering may require the global $post to be set. Other logic needs to know the current user.