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.

  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


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
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: