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

Reusable blocks - variables & placeholders #20240

Closed
christravelblog opened this issue Feb 14, 2020 · 7 comments
Closed

Reusable blocks - variables & placeholders #20240

christravelblog opened this issue Feb 14, 2020 · 7 comments
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.

Comments

@christravelblog
Copy link

Hi everyone!
I finally started to use gutenberg ;-)
This can replace quite some plugins I was using in the passed including re-usable content/blocks. BUT, not all reusable content is the same.
I want to be able to pass variables from the post into the reusable block. How do I do that?
For example I have a block containing stuff that goes below the conclusion paragraph. BUT, this contains 3 items that are different for each post but the text is always the same.

So, I want to be able to edit this text/images/whatever from the reusable blocks section. Works. BUT I want to add placementholders there for 3 items. Which I then want to put in the editor of the post. Example, I had reusable block X, and I give it Var1=A, Var2=B, Var3=C and it has to fill that on the placementholders of the block.

Any idea? I would prefer NOT to keep using a plugin for this as I think this could be default wordpress.

Chris.

@christravelblog christravelblog changed the title Reusable blocks issue - or I am missing this feature? Reusable blocks question - variables & placementholders Feb 14, 2020
@talldan talldan added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Feb 18, 2020
@talldan
Copy link
Contributor

talldan commented Feb 18, 2020

Hi @christravelblog. Hopefully I've not misunderstood, but It sounds like what you want to do is use the reusable block as a template.

If so, there's a way you can achieve that. You could create a reusable block as a template with some content filled out, but other blocks acting as placeholders. You can add that reusable block to your post and then use the 'Convert to Regular Blocks' option to make those blocks editable without having to create multiple variations of your original reusable block:
Screen Shot 2020-02-18 at 1 33 13 pm

Alternatively, if you're comfortable coding, you could also look at creating a block with a block template inside of it:
https://developer.wordpress.org/block-editor/developers/block-api/block-templates/

Is that helpful?

@christravelblog
Copy link
Author

Hi @christravelblog. Hopefully I've not misunderstood, but It sounds like what you want to do is use the reusable block as a template.

Hi,
That is working perfect :-) saves me the template plugin.
Note, what I want below is just BASIC. It doesn't have to go advanced this can be done with plugins which can offer much more (like ACF). But the very basics I think should be core.
No what I want is that in a re-usable block I can put for example:

BLOCK CONTENT: This is a test block, at [thisplaceholder var1] must go variable 1 that I add in the post itself. I want to be able to change this text, layout in 1 place, in the re-usable block section. At [thisplaceholder var2] must go. It must be blocked as a reusable block in the editor when used in a post.

This is a reusable block. When I add this block in the editor I want it to give a drop down in the block where I can fill in var1, var2 which it automatically gets from the [ ] in the reusableblocks. Whent he page is rendered it filles in these 2.

It's very basic; and just text is fine enough. If people want advanced stuff they can use ACF.
What I described above doesn't need to be called custom fields perse.

PS> for the moment I have ACF installed; which of course can do this. But for just a few variables and just text, the most basic stuff, I think this can be core?

Hope you get my point.
Is that something that COULD be added in gutenberg in the future? or is that already available but am I missing it? Or should I stick with ACF to make this happen even though it's just text what I need to insert.

@talldan talldan changed the title Reusable blocks question - variables & placementholders Reusable blocks - variables & placeholders Feb 18, 2020
@talldan talldan added [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement. and removed [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Feb 18, 2020
@talldan
Copy link
Contributor

talldan commented Feb 18, 2020

Yep, I follow the idea. I'll keep this issue open as an enhancement request in that case. I've updated the title to reflect that.

@christravelblog
Copy link
Author

Yep, I follow the idea. I'll keep this issue open as an enhancement request in that case. I've updated the title to reflect that.

Thank you. Of course I wouldn't make it to complex in the core. Just simple opiton with text fields.

@adbs1
Copy link

adbs1 commented Aug 19, 2021

It seems the 'Convert to regular block' context menu doesn't exist anymore, so this feature is needed more than ever.

image

@LeninZapata
Copy link

Hello, any progress with this feature? It's also useful for me right now.

@talldan
Copy link
Contributor

talldan commented Jun 14, 2024

I believe this will be possible using the Pattern Overrides feature that will be released in WordPress 6.6, which allows for changing/overriding some aspects of an instance of a pattern without changing the original pattern.

That work is/was being tracked in Introduce overrides in synced patterns iteration for WP 6.6, and there will continue to be improvements to the feature in future WordPress versions.

@talldan talldan closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants