My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
NavigationSystem  
The Navigation System
Phase-Design, Featured
Updated Sep 14, 2011 by truefus...@gmail.com

Structure

The navigation system of TFCMS is completely category-based, following a tree-like structure. The system conforms to standard practices by utilizing unordered lists for each part of the navigation. Items without any parents are considered root (top-level) items. A category has a parent if the category is a sub category.

Each category may have directories, links, and sub categories attached to them. The sub categories may have directories, links, and sub categories as well. Only one link/file may be attached to a item title, but any amount of directories and links may be attached to the category itself. Note that the link attached to the item title has higher priority than any file attached to it, so if you were to (unknowingly) set a link and a file to an item title, only the path to the link will be displayed.

The way the navigation is rendered takes into consideration CSS drop-down menus, therefore it should not be difficult to work with when desiring drop-down menus. Classes and IDs are specified for each category, making things even easier to work with.

File Names

When one of the categories link to a file or display a listing of files from a designated directory, the file name of those files are used to determine not only the URL for the file, but the title for the breadcrumb also. Note that special characters are removed from the file name when generating a URL for the file, but special characters are left untouched for the link names and breadcrumbs themselves. For breadcrumbs and navigation item titles, underscores will be converted to spaces.

Construction

As of revision 98, each category is represented by a TFCMSCategory object and each directory is represented by a TFCMSDir object. This allows for a more organized internal structure. To create a category simply instantiate a new TFCMSCategory object.

$category = new TFCMSCategory("Category Name", "Category ID");

There is no need to add the category to the current model as this is done automatically when instantiating a new category. The category ID is used to differentiate between two categories with the same name. Note that if a category is not instantiated with an ID, the name of the category will be used for its ID. If you create two categories with the same name but do not provide a unique ID for each, then the system will attempt to access the files from the category highest in the tree with the same name.

Adding Directories

To add a directory to a category simply instantiate a new TFCMSDir object and pass a category to the constructor.

$dir = new TFCMSDir("/full/path/to/directory", $category);

// Or...
$dir = new TFCMSDir("/full/path/to/directory");
$category->addDirectory($dir);

Adding sub-categories

To add a sub-category to an already existing category simply instantiate another category and pass the parent category to the constructor.

$sub = new TFCMSCategory("Sub-category Name", "Sub-category ID", $category);

// Or...
$sub = new TFCMSCategory("Sub-category Name", "Sub-category ID");
$category->addCategory($sub);

All category- and directory-relative information, therefore, is stored within each object respectively.

Simple (One-level) Navigation

Let's say you're not looking for a complicated navigation structure and only want a simple navigation structure, each item linking to a certain (internal or external) page. Aside from adding directories, each category is capable of linking to a file of choice or to an external page. After instantiating all root-level categories (i.e. categories without parent categories) you can attach a file or URL to the desired category through the methods setFile() or setUrl():

// File...
$category->setFile(__root."/path/to/file.ext");

// Or URL...
$category->setUrl("http://www.truefusion.org/");

You can also use the array index shorthand to set a file or URL to the category:

// File...
$category['file'] = __root."/path/to/file.ext";

// Or URL...
$category['url'] = "http://www.truefusion.org/";

Note that if you set both a file and URL to a category, the URL will take precedence over the file.


Sign in to add a comment
Powered by Google Project Hosting