View Single Post
Old 15.04.2004, 14:31   #10 (permalink)
richardt
Junior Mamber
 
richardt's Avatar
 
Join Date: Apr 2004
Location: Melbourne, Australia
Posts: 42
richardt is on a distinguished road
Send a message via MSN to richardt
Arrow Re: Using MAMBO much like Geocities

Righto, here's a heads up. This might take a minute to figure out, but grab the script from the above link and put it wherever you find the need to (I have the ThemeOffice directory under the template/{templatename} directory).

Then, above the initEditor() line in the template's index.php add the following:

Code:
<SCRIPT LANGUAGE="JavaScript" SRC="includes/js/JSCookMenu.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="templates/{templatename}/ThemeOffice/theme.js"></SCRIPT>
<LINK HREF="templates/{templatename}/ThemeOffice/theme.css" REL="stylesheet" TYPE="text/css" />
<?

$mymenu_content = <<<EOT
<SCRIPT LANGUAGE="JavaScript"><!--
var myMenu =
[
EOT;
      $database->setQuery("SELECT * FROM #__menu WHERE menutype = 'mainmenu' AND published ='1' ORDER BY ordering");
      $menus = $database->loadObjectList();   // mainmenu list
      $subs = array();   // sub menus
      // first pass to collect sub-menu items
      foreach ($menus as $row) {
         if ($row->parent) {
            if (!array_key_exists( $row->parent, $subs )) {
               $subs[$row->parent] = array();
            }
            $subs[$row->parent][] = $row;
         }
      }
      foreach ($menus as $row) { // second pass to insert main-menu items
         if ($row->parent == 0 && (trim( $row->link ) || array_key_exists( $row->id, $subs ))) {
            $name = addslashes( $row->name );
            $alt = addslashes( $row->name );
            $link = $row->link ? "'$row->link" : "null";
            if ($row->type != "url") {
               $link .= "&Itemid=$row->id'";
            } else {
               $link .= "'";
            }
            $mymenu_content .= "\n   ['<!img src=\"'+cmThemeOfficeBase+'arrow.png\">','$name',$link,null,'$alt'";
            if (array_key_exists( $row->id, $subs )) {
               $mymenu_content .= ',';
               foreach ($subs[$row->id] as $sub) { // third pass to insert sub-menu items
                  $name = addslashes( $sub->name );
                  $alt = addslashes( $sub->name );
                  $link = $sub->link ? "'$sub->link" : "null";
                  if ($sub->type != "url") {
                     $link .= "&Itemid=$sub->id'";
                  } else {
                     $link .= "'";
                  }
                  $mymenu_content .= "\n      ['<img src=\"'+cmThemeOfficeBase+'arrow.png\" width=\"13\">','$name',$link,null,'$alt'";

                  if (array_key_exists( $sub->id, $subs )) {
                     $mymenu_content .= ',';
                     foreach ($subs[$sub->id] as $sub2) { // forth pass to insert subsub-menu items
                        $name = addslashes( $sub2->name );
                        $alt = addslashes( $sub2->name );
                        $link = $sub2->link ? "'$sub2->link" : "null";
                        if ($sub2->type != "url") {
                           $link .= "&Itemid=$sub2->id'";
                        } else {
                           $link .= "'";
                        }
                        $mymenu_content .= "\n      ['<img src=\"'+cmThemeOfficeBase+'arrow.png\" width=\"13\">','$name',$link,null,'$alt'],";
                     }
                  }
                  $mymenu_content .= "],";
               }
            }
            $mymenu_content .= "],";
         }
      }

$mymenu_content .= "];\n";
$mymenu_content .= "--></SCRIPT>\n";

echo $mymenu_content;
?>
This will run through the entire Main Menu structure... just make sure you update the {templatename} references in the .js/.css links at the top. Hopefully I haven't lost you yet

Next, move to the spot in your template where you want the actual menu to appear. The idea here is that the menu is placed in a <div> container and is called with a Javascript command, so put the following in the exact spot where you want the menu to appear:

Code:
<DIV ID="myMenuID" align="center"></DIV>
<SCRIPT LANGUAGE="JavaScript"><!--
	cmDraw ('myMenuID', myMenu, 'hbr', cmThemeOffice, 'ThemeOffice');
--></SCRIPT>
I know this is a lot of info, and I'm sorry if I've confused people. I plan to publish this as a proper, constructed tutorial at some point in the next few days...I'm about to go into hospital so if you need a hand shoot me an email and I'll get to it when I can
__________________
Richard Thornton
http://richardthornton.com
richardt is offline   Reply With Quote