1
aubrey
moving "Main Menu" block to the top
  • 2004/2/10 1:41

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


I want to make my main menu show up where the banner ad normally shows up (right beside the logo in the top bar). I know I could just turn off the main menu block from the admin menu and copy the code for it into the template file but that would be clunky for several reasons. Is there a better way? One way I thought of (But don't know how to implement it), is to add a line of code to the template file near where the banner ad normally is that says something like "if (block == main menu) { put block here instead of anywhere else}" Forgive my code Is there any feasible way to do this while still preserving upgradeability and functionality?

Hope there is,

Aubrey

2
hsalazar
Re: moving "Main Menu" block to the top
  • 2004/2/10 2:38

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Aubrey:

What you intend to do is not really very practical, for several reasons. First, the main menu is dynamic: when you click on some modules, they open to show suboptions. Also, when you add a new module, its link appears automatically in the main menu (if you've set its weight to a value different from zero).

So, if you really want to have some (not all) of the menu options up there, in the header, you need to sacrifice some of the flexibility of the default menu.

Let's assume you absolutely need to place some options there. You can begin by exploring the x2t theme that comes included in your XOOPS distribution. This theme has a row of menu options on top. You can replicate this functionality for whatever options you want. Just check the way the links are built.

Another option is to go for a horizontal hierarchical menu, an option we're exploring for the upcoming opening of the XOOPS Net sites. This would sacrifice some functionality, but would give you more space and a different look.

Whatever you decide, don't be afraid to play with options, even if you think them "clunky". In the XOOPS world, playful exploration IS the way to go.

Cheers.

3
aubrey
Re: moving "Main Menu" block to the top
  • 2004/2/10 3:41

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


Actually I thought of all that already. If I can find out a way to dispay the menu block at the top I will break it into two rows (using css and tables). The top row will have the main links, and the bottom row will have the suboptions. As to just putting links into the top of the template, I would definiley not want to do that as then it could not be dynamic. All I really need is to know how to put the main menu block at a different place than all the other blocks.

Aubrey

4
hsalazar
Re: moving "Main Menu" block to the top
  • 2004/2/10 5:50

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


aubrey:

Actually, you can NOT put the main menu block in a place other than the side or center columns. What you CAN do is steal from the system module the PHP code that builds the main menu, and then insert that code into the file header.php or, as some prefer, into the file footer.php, including the Smarty assignments. Once you do that, you'll be able to put the Smarty variables in the file theme.html and there do whatever you want. For instance, create your two line menu in the top table.

Cheers.

5
aubrey
Re: moving "Main Menu" block to the top
  • 2004/2/10 20:56

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


I copied the below code (from system_block.php) into header.php right above the ?> tag:
Quote:
global $xoopsUser,$xoopsModule;
$block = array();
$block['lang_home'] = _MB_SYSTEM_HOME;
$block['lang_close'] = _CLOSE;
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$criteria->add(new Criteria('weight', 0, '>'));
$modules =& $module_handler->getObjects($criteria, true);
$moduleperm_handler =& xoops_gethandler('groupperm');
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$read_allowed =& $moduleperm_handler->getItemIds('module_read', $groups);
foreach (array_keys($modules) as $i) {
if (in_array($i, $read_allowed)) {
$block['modules'][$i]['name'] = $modules[$i]->getVar('name');
$block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname');
$sublinks =& $modules[$i]->subLink();
if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
foreach($sublinks as $sublink){
$block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
}
} else {
$block['modules'][$i]['sublinks'] = array();
}
}
}
return $block;


and this code into my template file (theme.html):

Quote:
<a class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a>
<{foreach item=sublink from=$module.sublinks}>
<a class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
<{/foreach}>
<{/foreach}>
<!-- end module menu loop -->


but when I log onto my site nothing happens (my site works, but the menu doesn't show up). I have the "Update module template .html files from themes/your theme/templates directory?" option set. I am sure I did something majorely wrong but don't know what.

P.S. {unrelated} why does my site's css (which looks great in IE) not even show up in Opera?

Thank you,

Aubrey

6
aubrey
Re: moving "Main Menu" block to the top
  • 2004/2/13 4:06

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


P.S. You can see my site here to get a better view of my problem:
My Site

Sorry I forgot to add that.

P.S. Am I being stupid or something? Howcome noone can help me

Aubrey

7
aubrey
Re: moving "Main Menu" block to the top
  • 2004/2/15 17:24

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


Yaay for GIJOE! I just noticed his site has the the same menu I am trying to do, and he gives the source for it! Although not fully dynamic, the submenus are, which will have to do.

You can now see the menus on my site,
AllThingsInteresting.com

P.S. Still have the css problem (although I am sure it's something I did).

Again, Yaay for GIJOE!

Aubrey

8
aubrey
Re: moving "Main Menu" block to the top
  • 2004/2/17 6:03

  • aubrey

  • Just popping in

  • Posts: 31

  • Since: 2004/2/1 2


Never mind, I figured out the css problem and it was all my fault Strange how Opera doesn't recognise the format of certain css tage while IE does (And vice versa)...

Login

Who's Online

217 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 217


more...

Donat-O-Meter

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

Latest GitHub Commits