PHP Classes
elePHPant
Icontem

multiXPandMenu: Generate dynamically expansible hierarchical menus

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   Screenshots Screenshots   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (5)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2005-09-01 (9 years ago) RSS 2.0 feedStarStarStarStar 74%Total: 4,239 All time: 652 This week: 1,204Down
Version License PHP version Categories  
xpandmenu 1.0BSD License3HTML
Description Author  

This class can create multi-level hierarchical menus based on a list of menu items and submenu items using DHTML.

The items organized in the generated menu can be expanded and collapsed dynamically using Javascript, that is when the user clicks on a menu item, all corresponding submenu items are shown, or hidden if already visible.

A good example of what it looks like is the list of documents and directories in the left frame of the Microsoft Windows Explorer.

The class provides means to create a root menu item and then add sub-nodes to it. To create more levels, it can add sub-nodes inside other sub-nodes. The menu may be arbitrarily deep.

The HTML code generated is only based on <UL> tags and is compatible with all browsers.

The generated menu is fully customizable using CSS. You may write your own CSS style definitions to configure the look and feel of parents and children menu items'.

The class also lets you define an image to use as the expand and collapse box. This is optional but can be handy to make the menu easier to understand.

Picture of Patrick Brosset
Name: Patrick Brosset <contact>
Classes: 3 packages by
Country: France France
Age: 35
All time rank: 19613 in France France
Week rank: 1504 Down42 in France France Down

Details provided by the author  
	+-----------------------------+
	| xPandMenu MULTI-LEVEL class |
	+-----------------------------+
	| Patrick Brosset             |
	| patrickbrosset@gmail.com    |
	+-----------------------------+
	| 02/2005                     |
	+-----------------------------+


	General
	-------
	
	The xPandMenu PHP class can help you create complex menus for your webpages.
	Items organised in the menu are displayed in a TreeView structure which
	resembles the MS Windows OS's directory explorer.
	
	The usage principle is simple:
	You first create a root object which will be the `base` of your menu.
	You then append `child` nodes to this root and `child` nodes to these nodes as well.
	The menu can have as many sub-levels as needed.
	
	
	Example
	-------
	
	This example shows how you can organise your items on your website using this PHP class.
	
	+ Home page
	+ About me
		+ my CV
		+ contact details
			+ email
			+ phone
	+ Photos
		+ Travels
		+ Parties
			+ my birthday
			+ ski trip
		+ Friends
	+ News
		+ PHP Classes
			+ XpandMenu class available on PHPClasses.org
	
	
	Benefits
	--------
	
	+ Each item in your list that contains sub-items can be collapsed / expanded by clicking on it.
	+ Each item in your list can be given a 2-states image that will be displayed next to the item
		and be swapped wheter the node is open or closed
	+ The entire menu-look can be highly changed through CSS
	+ The HTML code generated for the menu is only made of <UL></UL> lists
	+ The state of the menu can be saved from page to page
	+ The generated code may be saved once and for all for future use
	
	
	Requirements
	------------
	
	The menu's collapse/expand facility is done with Javascript. The client must have javascript turned-on to
	use the menu.
	The class was developed using PHP v 4.0.1
	
	
	Hoe to use the class?
	---------------------
	
	Please have a look through these 4 example files as they currently represent the only documentation available.
	I'll try to document the class itself soon.
	
	> example_simple.php
		Simple and basic example on how to use the main functions of the class
		You should be able to get started with this, although it is recommended to have a look at the other
		examples as well in order to use more interesting features
	
	> example_complex.php
		Still simple example on how to build a menu, but the menu is a lot more complex this time and 
		includes several sub-levels
		
	> example_SaveState.php
		This example builds the same menu as the previous example file but lets you save the state of your menu:
		When a user goes to another page which also displays the menu, you might want to display the menu as
		it was when the user left the previous page, that is, with expanded or collapsed nodes as they were.
		In this example, you learn how to simply call 2 Javascript functions that will save the state of the menu
		inside a cookie and then restore it from that same cookie.
		Warming: the user must allow cookies on his browser to ba able to use this feature.
	
	> example_reuseHTML.php
		In this example you also build the same complex tree but you are taught how to save the generated code
		in a file!
		Why? In some cases, your menu might not need to be dynimically generated every time, for instance if the
		menu is used to display links to your website's pages, these links might never change at all.
		The example helps you build a page that will:
		- generate the menu if it had not been generated before
		- save the generated code inside a file
		- and restore the menu from that file if it is found 
		
Screenshots  
  • screen_windows.gif
  • screen_expanded.gif
  • screen_collapsed.gif
  Files folder image Files  
File Role Description
Image file document_win.gif Icon Windows-style document icon
Plain text file example_complex.php Example Complex usage example
Plain text file example_dynamic.php Example Example file to learn how to create a menu dynamically from a multiple array of links
Plain text file example_reuseHTML.php Example Learn how to save the generated code to reuse it later
Plain text file example_SaveState.php Example Learn how to save the state of your menu in order to re-display it as is on another page
Plain text file example_simple.php Example Simple usage example
Plain text file File.php Class A simple file loader / writer used by the xPandMenu class to save the generated code
Image file folder_win.gif Icon Windows-style closed directory icon
Image file folder_win_o.gif Icon Windows-style open directory icon
Accessible without login Plain text file readme.txt Doc. READ ME FIRST
Plain text file xPandMenu.css Data CSS file to stylize the menu
Plain text file xPandMenu.js Data External javascript file for dynamic actions
Plain text file xPandMenu.php Class PHP class file

 Version Control Unique User Downloads Download Rankings  
 0%Total:4,239All time:652
 This week:0This week:1,204Down
 User Ratings  
 
 All time
Utility:94%StarStarStarStarStar
Consistency:92%StarStarStarStarStar
Documentation:82%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:74%StarStarStarStar
Rank:101