1
russtik
Modifying Menu Templates
  • 2005/2/2 11:33

  • russtik

  • Just popping in

  • Posts: 70

  • Since: 2004/8/13


Hello,

I would like to modify the core menu templates which in there standard state utilise tables. I intend to use an unordered list structure in replace of this:

<ul id="mainmenu">
  <{foreach 
item=module from=$block.modules}>
  <
li><a class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}></a></li>
    <
ul>
    <{foreach 
item=sublink from=$module.sublinks}>
    <
li><a class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a></li>
    <{/foreach}>
    </
ul>
  <{/foreach}>
</
ul>

The problem with the above code is that if a menu item doesn't have an attached submenu, it leaves unused < ul > tags in the markup which I don't want.

E.g.
<ul id="mainmenu">
  <
li>menu 1</li>
    [
b]<ul>
    </
ul>[/b]
  <
li>menu 2</li>
    <
ul>
      <
li>sub 1</li>
      <
li>sub 2</li>
      <
li>sub 3</li>
    </
ul>
</
ul>

Does anyone know how to include a conditional statement that says something like if (there is a submenu) show < ul > tags else hide them, or any other solution?