Source for file TigraMenu_example.php
Documentation is available at TigraMenu_example.php
* $Id: TigraMenu_example.php 127127 2003-05-15 16:23:09Z jrust $
* This example shows how to use the TigraMenu output driver
* @author Daniel Khan <dk@webcluster.at>
// This example assumes that you have allready set up DB_NestedSet and allready
// First you have to get TigraMenu
// It's available for free at http://www.softcomplex.com/products/tigra_menu/
// Please read the docs for TigraMenu - they are nice and verbose and will help
// you to understand the params passed to the driver
// No - I'll do no JavaScript support ;)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>{sitename}</title>
<script language="JavaScript" src="/js/menu_items.php">
<script language="JavaScript" src="/js/menu.js">
<script language="JavaScript">
new menu (MENU_ITEMS1, MENU_POS1, MENU_STYLES1);
Content of menu_items.php:
require_once('DB/NestedSet.php');
require_once('DB/NestedSet/Output.php');
// Choose a database abstraction layer. 'DB' and 'MDB' are supported.
// Set the DSN - see http://pear.php.net/manual/en/core.db.tut_dsn.php for details
$nese_dsn = 'mysql://user:password@localhost/test';
// Specify the database columns which will be used to specify a node
// Use an associative array. On the left side write down the name of the column.
// On the right side write down how the property will be called in a node object
// Some params are needed
"STRID" => "id", // "id" must exist
"ROOTID" => "rootid", // "rootid" must exist
"l" => "l", // "l" must exist
"r" => "r", // "r" must exist
"STREH" => "norder", // "order" must exist
"LEVEL" => "level", // "level" must exist
"STLNK" => "link" // Custom - specify as many fields you want
// Now create an instance of DB_NestedSet
if(PEAR ::isError ($NeSe)) {
echo $NeSe->getCode (). ": ". $NeSe->getMessage ();
// Fetch the tree as array
$nodes = $NeSe->getAllNodes (true );
'textField' => 'name', // Use the name column for the menu names
'linkField' => 'link', // Use the link column for the links
'currentLevel' => 1 // Start the ouput with this level
// This array contains the options needed
// for printing out the menu.
// The style properties for the top level
'textDecoration'=> 'none',
'border'=> "1px solid #FFFFFF",
'fontFamily' => 'Verdana, Arial, Helvetica, sans-serif',
// Set any JavaScript compatible style params here
// Note that this properties also have to exist in
// Set them to 'none' or other values there
'textDecoration'=> 'none',
'border'=> "1px solid #FFFFFF",
'fontFamily' => 'Verdana, Arial, Helvetica, sans-serif',
'fontWeight' => 'normal',
// Geometry sets the positioning and the
// proportions of the menu
// It can also be set for the top level and the sublevels
// Note that this properties also have to exist in
// Please look at the fine TigraMenu docs
// They have nice pictures describing the properties below
// Special settings are explained here
'childGeometry' => array (
// If you use '*' the width is considered to be x * max chars within this submenu
// This is useful if you want that the menu auto sizes with the menu item name's length
// The item width will can not be smaller than the root items with.
// You will have to try different values depending on the font/size you use
// If you want fixed with just remove the '*'
// Sets the horizontal offset between different levels
// In this case the first submenu level after the root will have no offset
// After that we will have -5 offset (overlapping) between the items
// Sets the vertical offset between different levels
// In this case the first submenu level after the root will have 20px offset
// After that we will have -10px offset (overlapping) between the items
'menu_id'=>1 // This is the menu id used to call the menu from JavaScript:
// new menu (MENU_ITEMS1, MENU_POS1, MENU_STYLES1);
// Now create the menu object, set the options and do the output
$menu->setOptions ('printTree', $options);
Documentation generated on Mon, 11 Mar 2019 15:37:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|