PHP Classes

PHP Menu Generator: Generate nested menus with HTML list items

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 760 All time: 4,441 This week: 36Up
Version License PHP version Categories
menu-generator 2.3Free For Educatio...5HTML, Templates, Design Patterns
Description 

Author

This class can generate nested menus with HTML list items.

It can compose a menu by adding root items and child items to its definition.

Menu items may be defined by text and optional links. The menu styles can be defined using CSS classes.

The class can also modify or remove items.

The composed menu can generate as an HTML list of items and saved to a file.

The class can also show the generated menu by loading the generated menu file.

Picture of mohamad Reza kavoosi
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

 

Example

<?php
require_once 'menuClass.php';
$menu=menu::init();
$item1=$menu->addRootItem('item0');
   
$item1->addChild('item1-1');
   
$item1->addChild('item1-2')->addChild('item1-2-1');
   
$item1->addChild('item1-3');
$menu->addRootItem('item1');
$menu->addRootItem('item2')->addChild('my profile','http://www.phpclasses.org/browse/author/916379.html','_blank');
$menu->addRootItem('item3');

//to remove ITEM :
/**
 $menu->removeItemByPath('0\1\0');
 OR
 $item1->remove();
**********************************************/
//TO Add css class for MENU,root item,child item :
/**
 $menu->cssClass= "classNames";
 $menu->GetItemByPath('0\1')->cssClass= "classNames";
**********************************************/
$menu->cssClass="menu";
//TO modify or edit Feature item :
/**
$menu->GetItemByPath('0\0\1')->title = "enter new title";
OR
$item1->title = "enter new title";
**********************************************/
if ($menu->save())
    echo
"The menu was created,Now you can <a href='index.php'>see menu</a>";




Details

with this class you can create and generate menu and list. Features this class is: 1- add items 2- add sub items 3- add css class for menu and items 4- access childs with path address 5- remove child 6- modify and edit childs 7- save menu

  Files folder image Files (5)  
File Role Description
Accessible without login Plain text file create.php Example create and modify menu at this file
Accessible without login Plain text file index.php Example example of how to use and show generated menu
Plain text file menuClass.php Class main class
Accessible without login Plain text file readme.txt Data read me file
Accessible without login Plain text file style.css Data style of menu

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:760
This week:0
All time:4,441
This week:36Up
User Ratings User Comments (2)
 All time
Utility:66%StarStarStarStar
Consistency:62%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:3123
 
Good job.
10 years ago (alexandru traian)
70%StarStarStarStar
HI Public members, Capital and small letter mixed, base64 fo...
10 years ago (keran)
2%Star