getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 227 forks source link

Request: Send current selected page to plugins to add/hide page blueprints. #1822

Open pamtbaau opened 4 years ago

pamtbaau commented 4 years ago

It is quite common for a plugin to check whether it should activate or not by checking the current uri/path against an 'enable_on_routes' config variable.

In Admin, this technique is cumbersome to implement (but doable) because the translated route of the selected page is not easily available.

This leads to the following issues:

Solution:

Suggestion:

mahagr commented 4 years ago

The current page logic is getting replaced with Flex Pages in Admin 1.10. It already has support for passing information as an event, though I've not looked into that for a long time and I'm not sure if it still works as intended.

pamtbaau commented 4 years ago

I've cloned admin 1.10 and its required flex-objects plugin.

I don't see much changes of first sight, but in AdminPlugin::initializeAdmin(), line 956 the Admin object is initialized. At that moment, Admin::page() returns the page selected by the user for editing.

That seems to me the right moment to fire an event containing the page.

On a side note: Admin 1.10 + flex-objects plugins seems to be much more responsive...

mahagr commented 4 years ago

The current version of flex plugin does not enable flex pages admin, it's enabled in the next version. You need to enable it from the plugin. Flex never calls Admin::page(). :)