Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

Best way to add something underneath every Markdown editor field in Admin?

admin

Started by Anna 6 years ago · 1 replies · 729 views
6 years ago

Hey everybody,

I would like to add something (a bit of text and some clickable characters) underneath every Markdown editor field in Admin. I see basically three ways I might achieve this:

  1. Create a new field type and add it manually via page blueprints. I don't like this option much because I'm doing this in a plugin, and people might have their own page templates and blueprints which they'd have to modify by themselves.
  2. Change the editor field by copying the original and adding my bit in. This seems fairly simple but a little hacky to me – what if the editor field changes at some point and I don't notice? Can I somehow just extend that original field?
  3. Use PHP to hook into the Admin pages at some point, check if there's an editor field, and add my bit via plugin code. That might be a good way, but I'm not too sure which hook to use, or how to check if there's an editor field…

Any ideas and pointers would be much appreciated!

👍 1
6 years ago

The Presentation-plugin does this for presentation.md-Pages, you could cut out what works there and use it. It does this by:

  1. Create a field specifically for the plugin.
  2. Add it via blueprints.
  3. Set the order to be below the editor.
  4. Hook into Admin to register the templates.

Of your ideas, 3 is most difficult in my estimation. It would even be easier to do that via JavaScript. 2 might have unintended consequences unless you manage to restrict it to specific Page Types. 1 is most viable, because the plugin's fields and templates can actually be overridden, because extensions can declare priority for events.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Vladimir Novak, 2 weeks ago
3 300 2 weeks ago
Plugins · by Mathieu Lecouturier, 3 weeks ago
3 278 3 weeks ago
Plugins · by Slebeig, 2 months ago
1 405 2 months ago
Plugins · by Rene, 2 months ago
2 575 2 months ago
Plugins · by Xavier, 3 months ago
2 491 3 months ago