Re: help me :)

From: Date: Mon, 30 Apr 2001 21:24:50 +0000
Subject: Re: help me :)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50915@lists.php.net to get a copy of this message
Arvydas, I did something like this using a "tree" structure, using stacks. Each item on the stack could have 1 to 3 properties: Name, Parent, URL. If the object on the stack has only a Name property (i.e. Parent and URL are empty) it is assumed that this item is a root node. If the item has a Name and a Parent, is is a child node to the parent, and if it has a Name, Parent and URL, then it is a leaf node to the parent. For example: FolderA FolderB --FolderB(1) --FolderB(2) --ItemB(2)(1) I push onto my stack directory items that have the following properties: AddDirItem(FolderA) AddDirItem(FolderB) AddDirItem(FolderB(1), FolderB) AddDirItem(FolderB(2), FolderB) AddDirItem(ItemB(2)(1), FolderB(2), http://itemb21.whatever) Then, you loop through all of the items, setting the root items as the top of the tree, and continue nesting subitems until you get to a new root item. If you want, I can send you the PHP objects I used to implement this in a dynamic tree. It works quite well, and is extensible to 'n', where 'n' is the number of items allowed due to system/browser constraints. Cheers, Jason "Arvydas" <arvys@delfi.lt> wrote in message news:E1ABE1DB7712E240.E8FE102A.arvys@delfi.lt... > Hello, > i'm new in php but i have very difficult exercise.... i must make hierarchical menu witch can be released for example so : > > First i will get main menu : for example menu1, menu2, menu3... and these menu will have links (this must be released with <a href=""...) to others submenu : sub1, sub2, sub3 (each menu can have more than one sub menu), and these submenus will go deeper and deeper (depends from some parameters) > so - the question is "How to make recursive menu ?" > (menu mus be repaint after any click...) > > (I have an idea to make function that will "produce" recursive arrays...) > > P.S.sorry for poor english :) > sincerely, > Arvys. >

« previous php.general (#50915) next »