Home arrow PHP arrow Page 3 - Building an Extensible Menu Class

What's On The Menu? - PHP

So you know the theory behind OOP, but don't really understandits applications? Well, it's time to take objects out of the classroom andinto the real world - this article demonstrates how OOP can save you timeand effort by building a PHP-based Menu object to describe therelationships in a hierarchical menu tree. And since the proof of thepudding is in the eating, it then combines the newly-minted Menu objectwith some of the most popular JavaScript menu systems available online toshow you how cool objects really are.

TABLE OF CONTENTS:
  1. Building an Extensible Menu Class
  2. Back To Class
  3. What's On The Menu?
  4. Children And Their Parents
  5. I Say Method, You Say Madness...
  6. Rounding Up The Family
  7. Saving My Bookmarks
  8. Reaching Higher
  9. Collapsing Inwards
  10. Extending Yourself
By: Team Melonfire, (c) Melonfire
Rating: starstarstarstarstar / 6
August 10, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
So that's the theory. Let's now spend a few minutes discussing the rationale behind the Menu object I plan to build.

Conceptually, a Web site can be considered as a combination of two things: menus and content. Menus are used to organize and classify the type of content, and to offer one or more navigational paths to specific content modules.

Now, although a menu may be visually presented in a number of different ways, there are certain common elements present in every menu:

1. Most menus are broken into levels, with each level more focused than the last; this hierarchical structure is sometimes referred to as a "menu tree".

2. Every menu tree consists of nodes connected to each other by branches.

3. A node may have one or more children, but can have only one parent.

Using these common principles, it is possible to build a Menu object which exposes certain generic methods. These methods will have nothing to do with the visual presentation of the menu tree; rather, they provide a simple API to various menu attributes and relationships, and can be used by client- or server-side scripts which are more closely connected to the presentation layer.

 
 
>>> More PHP Articles          >>> More By Team Melonfire, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap

Dev Shed Tutorial Topics: