PHP Classes

PHP side menu generator: Generate hierarchical menus defined in XML files

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Info   Screenshots Screenshots   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2014-08-04 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 384 All time: 6,216 This week: 1,060Up
Version License PHP version Categories  
side-menu-generator 1.0BSD License5.1HTML, Localization, PHP 5, Databases
Description Author  

This class generates hierarchical menus defined in XML files.

It reads given XML configuration file with a definition of a hierarchy of menus.

The class generates nested HTML lists and JavaScript code to present the defined menus in a Web page.

The texts used in the menus can be read for database using a separate localization class.

Picture of Vallo Reima
  Performance   Level  
Name: Vallo Reima is available for providing paid consulting. Contact Vallo Reima .
Classes: 4 packages by
Country: Estonia Estonia
Age: 58
All time rank: 23178 in Estonia Estonia
Week rank: 352 Up2 in Estonia Estonia Up
Innovation award
Innovation award
Nominee: 1x

Side menu generator and handler

These classes allow to configure and handle multilingual hierarchical side menus. The menu is generated server-side basing on the configuration. The menu item titles are selected from the multilingual database. The event listeners are attached client-side to handle the menu clicks and invoke selected actions.


The *texts.php* class loads the texts of specified language from a sqlite database (pdo_sqlite extension is required). *sidemenu.php* class loads the xml description into DOM object (libxml extension is required) and generates the menu's html using the titles supplied by *texts.php*. The client-side *sidemenu.js* class must be used to handle the menu.


*sidemenu.js* class presumes the menu structure created by *sidemenu.php* and certain html tag id's. It attaches the event handlers to the menu sections. Clicking any menu section causes the opening/closing of the submenu and/or invoking according action. The main window is kept to be adjusted to a full browser's window.

An example

The *example.php* forms a shell for functionality demonstration from the *example.phtml* template. The *example.sql* holds the vocabulary statements and an *example.db* sqlite database is created during first run. *example.xml* describes the menu structure to be created. *example.css* styles the shell and the menu inside it. The language token can be specified on startup: *example.php?en* or *example.php?lng=ru* etc. 

Change *example.db* and *example.xml* for your own menues. The xml node names must be specified in the texts table's code fields. Add the table columns for new languages (use ISO 639-1 notation). Design your own main window and modify the event listeners for real actions.

The package

The following files are included:

1. *sidemenu.php*  - class to generate the menu;
2. *sidemenu.js*  - class to handle the menu;
3. *common.js*    - support functions and classes;
4. *texts.php*  - class to supply language-dependent texts;
5. *example.php*  - demonstrating functionality;
6. *example.sql*  - multilingual texts base;
7. *example.xml*  - the menu configuration;
8. *example.phtml*  - the shell template;
9. *example.css*  - the shell an menu styles;

The *Side menu generator and handler* is implemented in vRegistry solution (see []) and vrManual program (see []).

  • sidemenu.png
  Files folder image Files  
File Role Description
Accessible without login Plain text file common.js Data Support functions and classes
Accessible without login Plain text file example.css Data The shell an menu styles
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file example.phtml Example The shell template
Accessible without login Plain text file example.sql Data Multilingual texts base
Accessible without login Plain text file example.xml Data The menu configuration
Accessible without login Plain text file Lic. License text
Accessible without login Plain text file Doc. Documentation
Accessible without login Plain text file sidemenu.js Data Class to handle the menu
Plain text file sidemenu.php Class Class to generate the menu
Plain text file texts.php Class Class to supply language-dependent texts

 Version Control Unique User Downloads Download Rankings  
 91%Total:384All time:6,216
 This week:0This week:1,060Up
 User Comments (1)  
2 years ago (Rahul Shambharkar)