Skip to content
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

Experiment with ServerSideRender #16

Closed
bobbingwide opened this issue Nov 29, 2018 · 4 comments
Closed

Experiment with ServerSideRender #16

bobbingwide opened this issue Nov 29, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Nov 29, 2018

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:

Block Shortcode Consideration
Oik-block/wp wp attributes: v, m, p
oik-block/geshi bw_geshi Generic Syntax Highlighting for lang=none,css,php,html,javascript,jquery
Oik-block/search bw_search
Oik-block/login bw_login consider protected content
Oik-block/list bw_list many attributes!
Oik-block/googlemap bw_show_googlemap needs to cater for Google’s JavaScript

For some logic the server side rendering may require the global $post to be set.
Other logic needs to know the current user.

@bobbingwide bobbingwide added the enhancement New feature or request label Nov 29, 2018
@bobbingwide bobbingwide self-assigned this Nov 29, 2018
bobbingwide added a commit that referenced this issue Nov 29, 2018
…shortcode. Uses simple string attributes: v, p and m
@bobbingwide
Copy link
Owner Author

See #12 for a summary of required blocks.

@bobbingwide
Copy link
Owner Author

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.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 15, 2018

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.

@bobbingwide
Copy link
Owner Author

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 bobbingwide/oik-bob-bing-wide#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant