HomeMySQL Page 2 - Data Management Made Easy Using Nennius: Creating a Web Application
Configuring a Web Application and Defining Its Menu - MySQL
Previously, we took a look at the Nennius engine and discussed several out-of-the-box features available to PHP developers. Now we are ready to create our own Nennius web application, and so we will discuss all of the steps necessary to do that.
The next step in creating a Nennius application is defining a menu structure. The menu configuration file ('config.menu.php’) contains two basic variables. The first, $nennius_menu_array, is an array specifying menu category names as keys, which in turn hold child arrays containing menu options for the category in question. Put another way each menu link is a self-describing array, contained by a larger array holding similarly grouped items, which is itself contained by yet another array – $nennius_menu_array.
For the purposes of our sample application, we will create one menu category, "Admin Options", and 2 menu options: “Manage Releases” and “Corporate Website”. Example code for doing this is provided below:
<?php # include config_defaults file for threshold values # NOTE: ignore a failed include for the purposes of the admin GUI @ include_once '../../config.defaults.php';
# intiialize nennius menu array $nennius_menu_array = NULL;
# globalize nennius menu array for access by Display Template $GLOBALS['nennius_menu_array'] = $nennius_menu_array; ?>
As you can see, each menu item contains several attributes: display name, hyperlink, and threshold. Perhaps the only one of these attributes that may not be self-explanatory upon first examination is the threshold. Nennius allows for 6 basic threshold levels: PUBLIC, CLIENT, USER, REVIEWER, MANAGER, and ADMIN. Every user is assigned a level, and in turn those levels are used to determine what content a user has access to as well as what operations a user may pform on specific content. For purposes of the menu configuration, a threshold level defines the minimum threshold required for a user to view a menu link. In our example above, any user (even one who has not yet logged in) will be able to view the "Corporate Website" link, but only ADMIN users will be able to view the link entitled "Manage Releases".
That's it. We've now defined a basic menu for our 'news' web app. (Note: Nennius will automatically generate 'login' and 'logout' menu options as well when appropriate.)