Reply to Re: Mysql Php dynamic menu UPDATE

Your name:

Reply:


Posted by Peter Fox on 07/14/05 13:11

Following on from Angelos's message. . .
>I have writen a class that does what I wanted except the UL LI part...
>anyway .I am going to paste you the code here.
>The logic of this script is part of phpLayersMenu in sourceforge but much
>simpler.
>If at anytime you redevelop that code, I would like to send me the changes
>...
>
>As far as I know it can display unlimited levels of menus.

It is one thing to be able to generate a 'tree' menu with nodes, sub
nodes etc but another to be able to open and shut dynamically using
javascript. What I have done is to write a class (actually 2 classes )
that interfaces with Tigra Tree ['free']
(www.softcomplex.com/products/tigra_menu_tree/). I've added the ability
to use templates at different levels. The test program below should
give you a flavour. Ask if you want the code (11k too big for news)


<?php
/*
menu tree
---------

This example populates a 2-level tree showing employees
by department. It illustrates templates for links.

Note the order in which items are added to the tree.
Always add item to tree/parent node BEFORE adding children to it
Nodes are added as references so unset() before re-using a node

Files required
../cl/menutree.phpc
../tools/mnu/tree.js
../tools/mnu/tree_tpl.js
graphic files as specified in tree_tpl.js

*/


require_once('../cl/menutree.phpc');

// dummy data
$departments=array();
$e1=array(1=>'Peter fox',2=>'Sally Fox',3=>'Geoffrey Fox');
$e2=array(11=>'Teddy fox',12=>'Jean Fox');
$departments[1]=array('Sales',$e1);
$departments[10]=array('Production',$e2);


// set up tree and organise templates
$t = new menuTree();
$t->AddLinkTemplate(1,'');
$t->AddLinkTemplate(2,'department.php?DEPT=[DID]');
$t->AddLinkTemplate(3,'employee.php?EMPNO=[EID]');

// highest level is always shown and doesn't collapse
$tnode = new treeNode('Employees by department');
$t->AddNode($tnode);

// populate tree
foreach($departments as $did=>$dept){
$departmentName=$dept[0];
$dnode = new treeNode($departmentName,array('DID'=>$did));
$tnode->AddChild($dnode);
$employeesOfDept=$dept[1];
foreach($employeesOfDept as $eid=>$employeeName){
$dnode->AddChild(new treeNode($employeeName,array('EID'=>$eid)));
}
unset($dnode);
}

// illustrate bypassing template using blank for data key
$snode = new treeNode('something special',array(''=>'myhomepage.php'));
$tnode->AddChild($snode);

// show it
print($t->CompleteMenu());

?>


--
PETER FOX Not the same since the poster business went to the wall
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация