I've made a patch that suits my need better, and I would like to have your opinion on the interest/validity of it.
It activates dynamic sub-menu without checking directories inclusion.
Nothing is changed, there's only 2 additions in the blocks/block.php file. I'll quote the normal code between my é addition to allow you to locate them.
My code - part 1(this code determines which main main is active):
$currentmainmenu = -1;
$opengroupheadermenu = -1;
$sql = "SELECT groups, link, submenu, title, target, imageurl, weight
FROM ".$xoopsDB->prefix('multimenu').$options[11]."
WHERE hide = 1
ORDER BY ".$options[3];
$result = $xoopsDB->queryF($sql ,$randlimit ,$rand);
while ( $myrow = $xoopsDB->fetchArray($result) ) {
// On teste si on est dans un menu principal
if($myrow['submenu'] == 0)
{
$currentmainmenu = $myrow['link'];
}
$isSub = substr_count($_SERVER['REQUEST_URI'], $myrow['link']);
if ($isSub>0)
{
$opengroupheadermenu = $currentmainmenu;
}
}
$currentmainmenu = -1;
Standard code just following:
$sql = "SELECT groups, link, submenu, title, target, imageurl, weight
FROM ".$xoopsDB->prefix('multimenu').$options[11]."
WHERE hide = 1
ORDER BY ".$options[3];
$result = $xoopsDB->queryF($sql ,$randlimit ,$rand);
while ( $myrow = $xoopsDB->fetchArray($result) ) {
$imenu['submenu'] = $myrow['submenu']; // fetch the value from database, is it a submenu?
$title = $myts->makeTboxData4Show($myrow["title"]);
if ( !XOOPS_USE_MULTIBYTES ) {
if (strlen($myrow['title']) >= $options[5]) {
$title = $myts->makeTboxData4Show(substr($myrow['title'],0,($options[5]-1)))."...";
} else {
$title = $myts->makeTareaData4Show($myrow['title']);
}
}
$groups = explode(" ",$myrow['groups']);
if (count(array_intersect($group,$groups)) > 0) {
if ( $options[4] == 1 ) {$imenu['title'] = $title;} else {$imenu['title'] = "";}
$alt_title = strip_tags($myrow['title']);
if ($myrow['link']) {
if ( (eregi("mailto:", $myrow['link'])) ||
(eregi("http://", $myrow['link'])) ||
(eregi("https://", $myrow['link'])) ||
(eregi("ftp://", $myrow['link'])))
{
$link = $myrow['link'];
} else {
$link = XOOPS_URL."/".$myrow['link'];
}
//-------------Added for showing submenu when actived-------
$imenu['showsub'] = 0;
//if ( (!empty($xoopsModule)) && (eregi("/".$xoopsModule->getVar('dirname')."/", $link)) ) {
if ( (!empty($xoopsModule)) && (eregi("/".$xoopsModule->getVar('dirname')."/", $link)) || $myrow['submenu'] == 1) {
$imenu['showsub'] = 1;
}
My code - Part 2, just following yours(this part activate sub menus according to the active main menu):
// On teste si on est dans un sous-menu dynamique
if($imenu['submenu'] == 2)
{
//On vérifie si le dernier menu principal est l'entête du groupe actif
if($currentmainmenu==$opengroupheadermenu)
{
$imenu['showsub'] = 1;
}
else
{
$imenu['showsub'] = 0;
}
}
// On teste si on est dans un menu principal
if($imenu['submenu'] == 0)
{
//On stocke les information relative à ce
$currentmainmenu = $myrow['link'];
}
Sorry for the french comments ;)
In advance, thanks for any advice or tips :)