forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: Henni on December 15, 2005, 03:16:50 pm
-
Hi,
I´d like to make themenu only visible to the admin user - I searched the forum and found this: http://forum.coppermine-gallery.net/index.php?topic=23771.0
But somehow this is not working - I´m using 1.4.2 and the solution was for 1.3.x -
I changed the line in themes.inc.php to '{SUB_MENU}' => USER_IS_ADMIN ? theme_main_menu() : '',
but it didn´t work...
any ideas?
-
I see two problems with your modifcation.
#1 theme_main_menu() needs to know which menu you actually want returned ie: theme_main_menu('sub_menu')
#2 Your editing themes.inc.php which is a No-No. (Why? because your mod will break any theme that uses the sub_menu to unhide the sys_menu like mac_ox_x)
Any time developers are tempted to look at editing themes.inc.php you should look at using a plugin instead.
In this particular case if you intend on making this work for themes like mac_ox_x it really is a requirement.
heres the suggested codebase:
// Add a filter
$thisplugin->add_filter('template_html','nosubmenu');
function nosubmenu($html)
{
if (!USER_IS_ADMIN) {
if (strstr($html,'MM_showHideLayers')) {
if (strstr($html,'id="SUB_MENU"')) {
$html=str_replace('{SYS_MENU}',"{SYS_MENU}<script type=\"text/JavaScript\">MM_showHideLayers('SYS_MENU','','show')</script>",$html);
} elseif (strstr($html,'id="Menu1"')) {
$html=str_replace('{SYS_MENU}',"{SYS_MENU}<script type=\"text/JavaScript\">MM_showHideLayers('Menu1','','show')</script>",$html);
}
$html=str_replace('{SUB_MENU}','<div style="visibility:hidden">{SUB_MENU}</div>',$html);
} else {
$html=str_replace('{SUB_MENU}','',$html);
}
}
return $html;
}
plugin attached.