1
mrgym
dynamic sub-menus - proposal to change the xoops menu?
  • 2003/10/2 19:33

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


How do I insert sub-menu options under my module name in the left menu WITHOUT using a non-standard module or shoveling globals before mainfile or header?

All I see is xoopsTpl->_tpl_vars[1] which contains html for the entire menu.



thanks!!!!

2
ackbarr
Re: dynamic sub-menus

I hope catzwolf doesn't get upset at me for giving away his tricks, but I noticed in a new module he was working on (WF-Channel) that he had a dynamic submenu. His trick was to add some code to xoops_version.php that retrieved his submenu records from a database and added them to the $modversion['sub'] array. In psuedo-code it looks something like this:
//Function defined in xoops_version.php
$arr getCustomSubMenus(); 
for (
$i=0$i<count($arr); $i++) {
  
$modversion['sub'][$i]['name'] = $arr['name'];
  
$modversion['sub'][$i]['url']  = $arr['url'];
}


3
mrgym
Re: dynamic sub-menus
  • 2003/10/3 13:11

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


Thanks very much! I'll look into it.

4
mrgym
Re: dynamic sub-menus - proposal to change xoops menus
  • 2003/10/4 18:59

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


(I can't find WF-Channel after looking here and modules.xoops2)

Unless I declare my own xoopsDB object this won't work.

modname/xoops_version.php is called early in header.php. So early that there isn't a xoopsDB object to use for a submenu!

IMO there should be a change in the way XOOPS menus are done. Options;
- header.php reads modname/xoops_version.php last(?)
- allow the module to add/ change xoopsTpl variables that represent menu sub-items. Change these into html (xoopsTpl->_tpl_vars.lblock[x].content) in footer.php


5
Herko
Re: dynamic sub-menus - proposal to change xoops menus
  • 2003/10/4 19:12

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


wf-sections can be found at http://wfsections.xoops2.com .

Herko

6
Mithrandir
Re: dynamic sub-menus - proposal to change xoops menus

I think what Mrgym wants is a menu with submenus, depending on the user status/groups.

I could use it myself for my Team Module. For anonymous users, there should only be links to Rosters and Matches - but for registered users (who are on a team) there should also be a link to the Tactics section. I have solved that with a module block - but it would be nice with it integrated in the main menu to avoid multiple navigation menus.

7
mrgym
Re: dynamic sub-menus - proposal to change xoops menus
  • 2003/10/5 13:08

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


Exactly! I want the ability to dynamically place submenu items under my appname in the lblock menu. I COULD place this submenu in "my" module cblock space, but that would be confusing from a usability standpoint AND take-up valuable screen space in the module area.

Specifically, I suggest moving the logic related to assembling the lblock menu to footer.php. The module could either declare an array of submenu URL's ($xoopsModule['vars']['submenu']?), or create a submenu array in xoopsTpl to be picked-up in the footer.php logic.

I can "hack" a solution where I declare a xoopsDB object in xoops_version.php and then unset() it, but the ability to create lblock submenus would be a great functionality to offer any module developer.




8
Catzwolf
Re: dynamic sub-menus - proposal to change xoops menus
  • 2003/10/6 10:32

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


try something like this:

global $xoopsDB;

$result = $xoopsDB->queryF("SELECT * FROM " . $xoopsDB->prefix("wfschannel") . " WHERE defaultpage = 0 ORDER by weight");
$i = 1;
while(list($CID, $pagetitle, $maintext, $weight, $groupid, $html, $smiley, $xcodes ) = $xoopsDB->fetchRow($result))
{
if (checkAccess($groupid))
{
$modversion['sub'][$i]['name'] = $pagetitle;
$modversion['sub'][$i]['url'] = "index.php?pagenum=" . $CID . "";
}
$i++;
}

9
mrgym
Re: dynamic sub-menus - proposal to change xoops menus
  • 2003/10/6 13:25

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


Thanks very much! People are very helpful here.

I had worked-through this with code that fetched the menu arrays, and then a module-specific .css file (like the ones I see for agendax and xCal) to provide offset and color context.

Correcting the mistake I made above.....
The xoopsDB object was located under $GLOBALS, so everyone can refer to it as $GLOBALS['xoopsDB'] .




10
Mithrandir
Re: dynamic sub-menus - proposal to change xoops menus

With register globals = on, I assume

Login

Who's Online

969 user(s) are online (72 user(s) are browsing Support Forums)


Members: 0


Guests: 969


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits