Data Management Made Easy Using Nennius: Creating a Web Application - Configuring a Web Application and Defining Its Menu
(Page 2 of 5 )
Configuring an Web Application For the purposes of our example application, our default configuration file will contain the following:
<?php
# name of application
$GLOBALS['nennius_application_name'] = 'News Manager';
# absolute path to current application on web server
$GLOBALS['nennius_application_path'] = '/nennius_server_path/webapps/news/';
# absolute URL to current application
$GLOBALS['nennius_application_url'] = 'http://www.corporatewebsite.com/nennius/webapps/news/';
# Nennius database connection variables - configure to match your SQL setup
$GLOBALS['nennius_db_type'] = 'mysql'; # ex. 'mysql', 'postgresql', 'oracle'
$GLOBALS['nennius_db_ip'] = 'localhost';
$GLOBALS['nennius_db_user'] = 'user';
$GLOBALS['nennius_db_pass'] = 'pass';
$GLOBALS['nennius_db_name'] = 'news';
?>
Defining an Application’s Menu 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;
# Manage Releases - links to Nennius page for adding & removing news releases
$admin_options_array[] = ( array( 'menu_display_name' => 'Manage Releases',
'menu_hyperlink' => 'index.php',
'menu_threshold' => $GLOBALS['ADMIN'] ) );
# Corporate Website - links to external corporate website to view changes in realtime
$admin_options_array[] = ( array( 'menu_display_name' => 'Corporate Website',
'menu_hyperlink' => 'http://www.corporatewebsite.com/news.php',
'menu_threshold' => $GLOBALS['PUBLIC'] ) );
# add all menus to nennius menu array
$nennius_menu_array['Nennius Menu'] = $admin_options_array;
# 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.)
Next: Creating SQL Tables >>
More MySQL Articles
More By Brian Vaughn