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

Consider allowing dynamic content from meta fields to be inserted inline in Paragraph, Heading, List, etc. #6665

Closed
ZebulanStanphill opened this issue May 9, 2018 · 9 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects

Comments

@ZebulanStanphill
Copy link
Member

ZebulanStanphill commented May 9, 2018

The issue and how existing page builders have solved it

Currently, there is no easy way to have inline dynamic content sourced from custom (or even non-custom) fields in Gutenberg.

Somewhat recently, Beaver Builder has gained the ability (through the official Beaver Themer extension) to easily insert dynamic content into any text or image field from any meta field, including (but not limited to) featured image, post title, post date, post modified date, excerpt, archive, site title, and any custom fields.

I highly recommend checking this feature out and playing around with in the demo to see how it works. It is quite powerful.
https://www.wpbeaverbuilder.com/beaver-themer/

Elementor Pro has also gained this functionality recently, albeit slightly less powerful: you can only have the dynamic content take up the entire text field, whereas Beaver Themer allows you to use it mixed in with standard static content by using the Insert button instead of Connect. (The Insert button uses a shortcode.)
https://elementor.com/introducing-theme-builder/

Divi is also working on implementing this same functionality in pretty much the same way as Elementor Pro:
https://www.elegantthemes.com/blog/theme-sneak-peeks/divi-feature-sneak-peek-dynamic-content

Approaching the issue in Gutenberg

Technically, you could just use some kind of shortcodes plugin to add dynamic content from fields into text inputs. However, Gutenberg is aiming to replace most, if not all shortcode usage. Therefore, I think that Gutenberg should have some kind of system in place for inserting inline (or in some cases not inline, but still within an existing block) dynamic content sourced from fields into text inputs (and possibly also image inputs).

Some example use cases:

  • A user could create a shared block made from a Paragraph block containing the phrase “This post was posted on XX:XX”, where XX:XX would be the publish date of the post. The user would be able to easily modify this block to change the wording and position of the time in the sentence, without having to create a custom block or write any code.
  • A user could insert an image block and have it show the featured image of the post. This could eliminate the need for a Featured Image block. (Though there is nothing stopping it from existing in addition to the ability to use featured images in any image input.)
  • In the future when Gutenberg is used outside of post_content, the Heading block could be re-used for the Post Title without having to create a dedicated Post Title block.

As for how to implement it, the first idea that comes to mind is doing it through the inline block/token system proposed by #2043. The only flaw I can think of at the moment to doing it through that system is that it does not provide a way for the dynamic content to be used in inspector inputs that are not shown outside of the sidebar.

Assuming I understand the inline block/token system, it seems like it could also allow for things that none of the page builders do right now, like an inline block/token that lists the categories, tags, or other taxonomical terms of a post. There are definitely some exciting possibilities to look into there.

Related Issues and/or PRs

#1851
#2043
#6663

@rchipka
Copy link

rchipka commented May 9, 2018

Also check out the "slot" concept on this issue

@danielbachhuber danielbachhuber added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience labels May 14, 2018
@danielbachhuber
Copy link
Member

Thanks for the suggestion, @SuperGeniusZeb. I've filed this to the Ideas project for future consideration.

@aristath
Copy link
Member

I've filed this to the Ideas project for future consideration.

I've seen this mentioned multiple times so I'm just curious... Where is this Ideas project? I can't find anything on github 🤔

@danielbachhuber
Copy link
Member

@aristath
Copy link
Member

Ah gotcha! Thanks 👍

@gravnetic
Copy link

How come this issue was put into a project and closed, and then that project was closed? That seems like a really unusual way to concatenate issues.

@ZebulanStanphill
Copy link
Member Author

I've been told this sort of thing is now possible to implement with the Format API. Not exactly sure how to use it to do this, but in case anyone is wondering if it's possible with the existing APIs, this should help.

@ZebulanStanphill
Copy link
Member Author

This issue was originally intended to suggest that a visual UI be added for inserting inline dynamic content, but in hindsight, I think that's something best left to plugins, at least until there's noticeable demand for the feature. The upcoming full site editing and related blocks will likely provide the functionality most users are looking for. Since it is technically possible for plugins to implement this now, I'm leaving this issue closed.

@ZebulanStanphill
Copy link
Member Author

Actually, it looks like it might be a bit difficult to implement this? See #18490 for continued discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.
Projects
No open projects
Ideas
Awaiting triage
Development

No branches or pull requests

5 participants