forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: Gwyneth Llewelyn on August 17, 2009, 01:44:50 am

Title: [Invalid]: Such a simple question: how to add a new button under SYS_MENU? (via a plugin)
Post by: Gwyneth Llewelyn on August 17, 2009, 01:44:50 am
Hi,

I'm changing the mac_ox_x theme, and wish to add a new menu item without touching the theme's template files (http://forum.coppermine-gallery.net/index.php/topic,59868.0.html) (to make sure they remain untouched for possible upgrades). The menu item should be under the SUB_MENU (which almost nobody seems to like to do) instead of the SYS_MENU (which everybody seems to love (http://forum.coppermine-gallery.net/index.php/topic,37612.0.html), and it took me 30 seconds to locate at least three different ways of doing this, all of them working flawlessly).

Sadly, changing the SUB_MENU seems to be far less popular than the SYS_MENU. After spending several hours browsing through the forum, I still haven't found a working solution.

The plugin manual (for 1.5...) suggests:
Code: [Select]
<?php
$thisplugin
->add_filter('sub_menu','add_sub_button');<br />

function 
add_sub_button($menu) {
    
$new_button = array();
    
$new_button[0][0] = 'MENU LINK';
    
$new_button[0][1] = 'menu link';
    
$new_button[0][2] = './menu_link.php';
    
$new_button[0][3] = 'class_name';
    
$new_button[0][4] = '::';
    
$new_button[0][5] = 'rel="nofollow"';

    
array_splice($menucount($menu)-10$new_button);

    return 
$menu;
}

That's very nice, but a) I don't know what all of those options mean (why the duplication on
Title: Such a simple question: how to add a new button under SUB_MENU? (via a plugin)
Post by: Gwyneth Llewelyn on August 17, 2009, 01:48:25 am
Sorry, the topic should be

Quote
Such a simple question: how to add a new button under SUB_MENU? (via a plugin)
and not

Quote
Such a simple question: how to add a new button under SYS_MENU? (via a plugin)

Also, I should have put :: under teletype tags and not code tags.

Sadly I can't change the original post!!! My apologies!
Title: Re: Such a simple question: how to add a new button under SYS_MENU? (via a plugin)
Post by: Gwyneth Llewelyn on August 17, 2009, 01:53:41 am
I should also add that in the mean time I've gone through the Coppermine Forum Plugin (http://forum.coppermine-gallery.net/index.php/topic,51535.0.html), which allegedly also changes the SUB_MENU and not only the SYS_MENU, using almost identical code for both. That's pretty advanced "magic" for me, and adapting it for my own plugin, it definitely works flawlessly for the SYS_MENU (it basically assumes that SYS_MENU is tagged with comments, which it is; but it also assumes that SUB_MENU has similar tags, which it doesn't — at least, not under the default [ie. untweaked] mac_ox_x theme).
Title: Re: Such a simple question: how to add a new button under SYS_MENU? (via a plugin)
Post by: Joe Carver on August 17, 2009, 01:56:12 am
I think you might be a bit off track in your assumption about theming and templates.

....without touching the theme's template files (to make sure they remain untouched for possible upgrades)

Your 1.4x themes and templates are exactly what you reuse and keep as you upgrade.

So my suggestion is to use the template and theming options that are given....
Title: Re: Such a simple question: how to add a new button under SYS_MENU? (via a plugin)
Post by: Gwyneth Llewelyn on August 17, 2009, 02:48:36 am
Well, you might be right, of course, I'm basing my assumption on just the revision numbers of the mac_ox_x template, which changed while upgrading Coppermine. To be honest, I haven't done a step-by-step comparison to see if there was, indeed, a change besides the revision number (and minor copyright disclaimers on some headers). Perhaps there weren't any changes. I don't know. That's exactly my point here: I don't know, and I can't know, if something changes on the theme templates from one version to the other (imagine, for instance, that the next version has an extra button, or the whole templating system is redone from scratch). To be completely sure that during an upgrade any problems that arise are only my fault (and nobody else's), I prefer to leave the templates as untouched as possible.

Worse than that — if I change a template and theme.php for a template too much, it will be a pain to make sure that a particular plugin will continue to work if someone changes the template later on (even if the Coppermine version does not change). And both things, of course, might happen simultaneously: on a future version, Coppermine's templating engine might change dramatically and all themes are suddenly much more feature-rich — except for my own, which will be old, clunky, and incompatible — while the plugin, of course, will not work with any other theme except my own tweaked one.

By putting all possible changes inside plugins and not themes at least I have just one thing to change due to a dramatic upgrade. If something fails, it's just the plugin — the rest of the Coppermine install remains perfectly functional. So I have just one person to blame and one section of code to rewrite: the plugin.

Furthermore, I don't see (yet) how I can add multi-language support to themes without using plugins (I mean, if I need completely new buttons and elements that are not on the "mainstream" themes). Granted, I can replicate the whole multi-language support on theme.php, and create new "lang" directories for that particular theme, but this is really overkill. Or, of course, I can make a theme so bound to the plugin that it will only work with that plugin installed and nothing else (since plugins have a reasonably well-documented approach to multi-language support). Both approaches do not make much sense to me.

So what you're suggesting is that instead of adding a button via a plugin I should simply redesign a new template and a new multi-language support engine just for that theme?
Title: Re: Such a simple question: how to add a new button under SYS_MENU? (via a plugin)
Post by: Joachim Müller on August 17, 2009, 08:41:56 am
It's a pity that you keep on refering to cpg1.5.x. I already told you in the other thread where you asked questions about cpg1.5.x that you mustn't do that yet, because cpg1.5.x goes unsupported. Specifically on the cpg1.4.x support board it's a bad idea to refer to cpg1.5.x things, as it's confusing and misleading.
Marking thread accordingly and locking.