Is it possible to overwrite a blueprint, instead of extending it?
Not quite sure I get what you are trying to achieve. You can override a blueprint defined in a plugin by putting a blueprint with the same name into your /site/blueprints/pages
folder.
I have this blueprint field:
label: "Select one option"
type: select
options:
- vertical: Vertical
- horizontal: Horizontal
- mixed: Mixed
I want to add a new option at the end of the list, like this:
options:
- vertical: Vertical
- horizontal: Horizontal
- mixed: Mixed
- <--- NEW OPTION HERE
I want to add this value using a plugin.
I know I can create a new blueprint, and extend the original field, but I would end up with a whole new blueprint which I don’t need. I just want to add a new value.
Thanks for your help.
Depending on what condition?
Possible options include using conditional fields or getting your options from an API.
I’m trying to create a plugin that adds extra options to a field that already exists.
This field will be used in templates to load a snippet()
.
I see various ways to do this, but as of now, all I need is to add an extra value to an existing blueprint field.
Again, I think there are various ways to that but it depends on your use case. If you have to inject it on the fly for some reason, you have to do it on the JavaScript side. Otherwise you can do it via API options or whatever. That’s why I was asking on what condition this additional value depends.
One way to approach the question is: How to create a blueprint field that displays a list of options that a plugin can also extend?
The selected option will be used to load a snippet.
There is no condition (I guess), except for installing the plugin. Sorry if I fail to express myself.
Overriding the field itself from a plugin is not possible, because if you register a field blueprint in a plugin, it will be overridden with the same field blueprint in the site folder.
But I somehow fail to see the use case. If you have to add this field anyway when you use the plugin, you might as well add the extra option(s)? How would your plugin know what field to extend otherwise?
Thanks @texnixe
I work on themes (not websites directly). I’m exploring the idea of extending blueprints via plugins. This would allow me to ship some features for my themes as plugins.
Right now I can add whole new blueprints/templates via plugins to my themes, great! But I cannot extend blueprints that already exist.
Extending blueprints would be particularly useful for me. I understand if I don’t represent the need of most developers. I am just exploring the idea for themes.
Summary:
- It is possible to add new blueprints via plugins
- It is NOT possible to extend existing blueprints via plugins
Still very thankful for your help. You are great!