More items in print_plugin_admin?

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

More items in print_plugin_admin?

Post by svasti » Wed Jun 25, 2014 4:13 pm

Now the standard is:
Main Settings -- Stylesheet -- Config -- Language -- Help

Would be nice, if more items could be added, at least --about--, sometimes something like --preview-- would also make sense.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: More items in print_plugin_admin?

Post by cmb » Wed Jun 25, 2014 5:41 pm

Well, print_plugin_admin() builds up the items automatically from what is there (stylesheet, config file, language file, help file); there is only a single option that can be controlled by the developer: whether the "Main Settings" will be shown. However, print_plugin_admin() is just a facade for pluginMenu(), which could be used directly. And it is possible to add another row with menu items, e.g. (from Register_XH):

Code: Select all

    $o .= print_plugin_admin('off');
    pluginmenu('ROW');
    pluginmenu('TAB', '?&register&admin=plugin_main&action=editgroups', '', $plugin_tx[$plugin]['mnu_group_admin']);
    pluginmenu('TAB', '?&register&admin=plugin_main&action=editusers', '', $plugin_tx[$plugin]['mnu_user_admin']);
    $o .= pluginmenu('SHOW');
Basically, I neither like the way the menus are marked up as tables (a list would be more flexible), nor do I like the procedural interface which is clumsy and overly flexible.

And since XH 1.6.2 there is XH_registerPluginMenuItem and its facade XH_registerStandardPluginMenuItems, which really serves the same purpose.

Even though XH_registerPluginMenuItem() offers far less flexibility than pluginMenu(), it seems to me the API is sufficient. So what about the following idea?

Code: Select all

function print_plugin_admin($main)
{
    if (hasRegisteredItems($plugin)) {
         // emit plugin menu with all registered menu items
    } else {
         // emit plugin menu as it is now
    }
}
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: More items in print_plugin_admin?

Post by svasti » Wed Jun 25, 2014 11:46 pm

I played around a bit with XH_registerPluginMenuItem, but it is not really necessary for my plugins. It's fine for plugins which have the "about" as plugin_main. But it makes for a complicated plugin dropdown menu.

What about a setting so that XH_registerPluginMenuItem don't create an additional plugin dropdown menu but an additional item in the print_plugin_admin without adding another row?

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: More items in print_plugin_admin?

Post by cmb » Thu Jun 26, 2014 11:53 am

svasti wrote:I played around a bit with XH_registerPluginMenuItem, but it is not really necessary for my plugins.
I didn't mean to suggest that you solely use the new plugin menu, but that instead both plugin menus could be build from XH_registerPluginMenuItem(). You may try the following draft replacement of print_plugin_admin();

Code: Select all

function print_plugin_admin($main)
{
    global $plugin, $_XH_pluginMenu;

    initvar('action');
    initvar('admin');
    $items = XH_registerPluginMenuItem($plugin);
    if ($items) {
        $html = '<ul style="list-style:none; padding-left:0; margin-bottom:1em">';
        foreach ($items as $item) {
            $html .= '<li style="float:left; padding-right:1em">'
                . '<a href="' . XH_hsc($item['url']) . '">'
                . XH_hsc($item['label']) . '</a>'
                . '</li>';
        }
        $html .= '<div style="clear:left"></div>' . '</ul>';
        return $html;
    } else {
        return $_XH_pluginMenu->render(strtoupper($main) == 'ON');
    }
} 
svasti wrote:It's fine for plugins which have the "about" as plugin_main. But it makes for a complicated plugin dropdown menu.
And it lets the user quickly access the help file, for instance, so he could look up the syntax of the plugin call.
svasti wrote:What about a setting so that XH_registerPluginMenuItem don't create an additional plugin dropdown menu but an additional item in the print_plugin_admin without adding another row?
We have to consider small content areas; adding another cell to the plugin menu could easily bust the layout--actually that might already happen, particularly when the user is using long labels for the menu items. You can see a relatively harmless, but IMO unpleasant, effect, when requesting Pagemanager's administration in Responsivehtml, for instance.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply