PHP
  Home arrow PHP arrow Building an Extensible Menu Class
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building an Extensible Menu Class
By: Team Melonfire, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2001-08-10


    Table of Contents:
  • Building an Extensible Menu Class
  • Back To Class
  • What's On The Menu?
  • Children And Their Parents
  • I Say Method, You Say Madness...
  • Rounding Up The Family
  • Saving My Bookmarks
  • Reaching Higher
  • Collapsing Inwards
  • Extending Yourself

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building an Extensible Menu Class
    ( Page 1 of 10 )

    So you know the theory behind OOP, but don't really understand its applications? Well, it's time to take objects out of the classroom and into the real world - this article demonstrates how OOP can save you time and effort by building a PHP-based Menu object to describe the relationships in a hierarchical menu tree. And since the proof of the pudding is in the eating, it then combines the newly-minted Menu object with some of the most popular JavaScript menu systems available online to show you how cool objects really are.How many times have you sat down to code a script and - halfway through - thought to yourself, "Didn't I do something similar just last week?"

    If you're anything like the average Web developer, you probably ask yourself this question at least once every few days. And more often than not, you're torn between coding the same functions again (because you're already halfway there and looking for last week's code just isn't worth the effort) and spending an hour searching for that itty-bitty script on your twenty-terabyte hard drive (because it's just more convenient to modify last week's code than to write it all over again.)

    It's to resolve precisely this sort of dilemma that a bunch of white-haired software gurus (who, according to legend, live on a snowy mountain peak in the Himalayas and spend most of their time coding algorithms to calculate the value of pi to the nth decimal) came up with the concept of object-oriented programming. Very simply, object-oriented programming allows developers to create reusable, extensible program modules in order to speed up code development and maintenance.

    Now, you may not know this, but my favourite language and yours, PHP, comes with some pretty powerful OOP capabilities. And over the course of this article, I'm going to demonstrate some of them by building an object to address a very common task - generating a menu tree on a Web site. That's not all, though - once I've successfully created a Menu object, I'm going to torture-test it with some of the most popular menu systems available on the Web to see if it does, in fact, offer any significant advantages.

    If all goes well, this experiment should teach you a little about the theory and possible applications of OOP; provide you with a Menu class which is (hopefully) useful to you in your development activities; and perhaps even spark off some ideas for using PHP classes in your next project. If, on the other hand, I crash and burn, you'll have something to snicker over at the pub tonight.

    Sounds like fun? Keep reading.

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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT