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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

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

admin

Started by Anna 6 years ago · 1 replies · 606 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 Rene, 1 week ago
2 54 1 week ago
Plugins · by Xavier, 4 weeks ago
2 61 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1188 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 54 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 79 2 months ago