Welcome to Geeklog, Anonymous Friday, April 18 2025 @ 09:26 am EDT
Geeklog Forums
Menu Plugin - Enhancement
Status: offline
THEMike
Forum User
Moderator
Registered: 07/25/03
Posts: 141
Location:Sheffield, UK
I\'ve just enhanced the menu plugin I found on this site. I amended the code to expand a menu, it now goes to $PHP_SELF and appends the query string. So if you have a collapsed admin menu, you can expand it out without losing your current page. Should you want to.
[php]
/**
* Actual code that generates menu
*
*/
function phpblock_menu_plugin() {
global $_CONF, $_USER, $menu, $CONFIG_MENU,$PHP_SELF,$_GET;
/* MIKE: get the query string,
this will allow us to go back to the right page */
$qstr = \'\';
while( list($key,$value) = each( $_GET ) )
{
$qstr .= \"&$key=$value\";
}
$result = DB_query(\"SELECT * FROM mnu_user WHERE owner_id=\'\" . $_USER[\'uid\'] . \"\' ORDER BY m_pos ASC\");
$nrows = DB_numRows($result);
if ($nrows == 0) {
$result = DB_query(\"SELECT * FROM mnu_index WHERE \" . MNU_getPerms() . \" AND (lang = \'{$_USER[\'language\']}\') ORDER BY m_pos ASC\");
// com_errorlog(\"SELECT * FROM mnu_index WHERE \" . MNU_getPerms() . \" AND (lang = \'{$_USER[\'language\']}\') ORDER BY m_pos ASC\",1);
$nrows = DB_numRows($result);
}
// com_errorlog(\"nrows = $nrows language = \" . $_USER[\'language\'],1);
if ($nrows == 0) {
$result = DB_query(\"SELECT * FROM mnu_index WHERE \" . MNU_getPerms() . \" AND (lang = \'{$CONFIG_MENU[\'language\']}\') ORDER BY m_pos ASC\");
$nrows = DB_numRows($result);
}
$T = new Template( $_CONF[\'path_layout\'] );
$T->set_file( \'option\', \'useroption.thtml\' );
$T->set_var(\'layout_url\',$_CONF[\'layout_url\']);
$TL = new Template($_CONF[\'path\'] . \'/plugins/menu/templates\');
$TL ->set_file(\'label\',\'menubar.thtml\');
$menua = explode(\'_\',$menu);
for ($i=0;$iset_Var( \'option_url\', $_CONF[\'site_url\'].\"$PHP_SELF?menu=\".$A[\'m_label\'].$qstr );
$T->set_var( \'option_label\', $tmp . $labela[$sz - 1] . \' \' . $CONFIG_MENU[\'chevron\']);
} else {
$T->set_var( \'option_url\', $A[\'m_url\']);
$T->set_var( \'option_label\', $tmp . $labela[$sz - 1]);
}
$T->set_var( \'option_count\',\'\');
$retval .= $T->parse( \'item\', \'option\' );
}
} else {
if (substr($A[\'m_label\'],strlen($A[\'m_label\'])-1,1) == \'_\') {
$tmp = substr($A[\'m_label\'],0,strlen($A[\'m_label\'])-1);
if (sizeof(explode(\'_\',$tmp)) > 1) { break; }
$T->set_var( \'option_label\', $tmp . \' \' . $CONFIG_MENU[\'chevron\']);
$T->set_Var( \'option_url\', $_CONF[\'site_url\'].\"$PHP_SELF?menu=\".$A[\'m_label\'].$qstr );
} else {
if (sizeof(explode(\'_\',$A[\'m_label\'])) > 1) { break; }
$T->set_var( \'option_label\', $A[\'m_label\']);
$T->set_var( \'option_url\', $A[\'m_url\']);
}
$T->set_var( \'option_count\',\'\');
$retval .= $T->parse( \'item\', \'option\' );
}
break;
case \'2\';
$TL->set_var(\'m_label\',$A[\'m_label\']);
$retval .= $TL->parse(\'item\',\'label\');
break;
case \'3\';
if ($A[\'m_label\'] != \'\') {
$TL->set_var(\'m_label\',$A[\'m_label\']);
$retval .= $TL->parse(\'item\',\'label\');
}
$retval .= MNU_showTopics();
break;
case \'4\';
case \'5\';
if ($A[\'m_type\'] == \'4\') {
$tmp = MNU_userMenu();
} else {
$tmp = MNU_adminMenu();
}
if ($tmp != \'\') {
if ((substr($A[\'m_label\'],strlen($A[\'m_label\'])-1,1) == \'_\') && ($menu != substr($A[\'m_label\'],0,strlen($A[\'m_label\'])-1)) && ($_USER[\'uid\'] > 1)) {
$T->set_Var(\'option_url\', $_CONF[\'site_url\'].\"$PHP_SELF?menu=\".substr($A[\'m_label\'],0,strlen($A[\'m_label\'])-1).$qstr );
$T->set_var(\'option_label\',substr($A[\'m_label\'],0,strlen($A[\'m_label\'])-1) . \' \' . $CONFIG_MENU[\'chevron\']);
$T->set_var(\'option_count\',\'\');
$retval .= $T->parse(\'item\',\'option\');
} else {
if ($A[\'m_label\'] != \'\') {
if (substr($A[\'m_label\'],strlen($A[\'m_label\'])-1,1) == \'_\') {
$TL->set_var(\'m_label\',substr($A[\'m_label\'],0,strlen($A[\'m_label\'])-1));
} else {
$TL->set_var(\'m_label\',$A[\'m_label\']);
}
$retval .= $TL->parse(\'item\',\'label\');
}
$retval .= $tmp;
if (substr($A[\'m_label\'],strlen($A[\'m_label\'])-1,1) == \'_\') {
$TL->set_var(\'m_label\',\'\');
$retval .= $TL->parse(\'item\',\'label\');
}
}
}
break;
}
}
return $retval;
}
[/php]
15
14
Quote
Status: offline
destr0yr
Forum User
Full Member
Registered: 07/06/02
Posts: 324
i get this:
Parse error: parse error, expecting `')'' in /home/okanagan/plugins/menu/functions.inc on line 360
line 359-361 of gl_dir/plugins/menu/functions.inc:
$T->set_var( 'option_label', $tmp . $labela[$sz - 1] . ' ' . $CONFIG_MENU['chevron']);
} else {
-- destr0yr
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams
Text Formatted Code
for ($i=0;$iset_Var( 'option_url', $_CONF['site_url']."$PHP_SELF?menu=".$A['m_label'].$qstr );$T->set_var( 'option_label', $tmp . $labela[$sz - 1] . ' ' . $CONFIG_MENU['chevron']);
} else {
-- destr0yr
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams
14
17
Quote
All times are EDT. The time is now 09:26 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content