SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I build my script to allow extension modules?

    I see some scripts, they build in such a way where other people can write their extensions to incorporate with the main script. Scripts like Joomla, allows something like this. The problem is how do these scripts then read the extension scripts and accept it as one of its module and work together? What is the idea behind for the third party script and their own script to work together? How can I build something like this for mine?
    I Googled for something like this but I think I am not sure with the keywords and that's why I am not getting any results I am looking for.

    Thanks!

  2. #2
    SitePoint Addict
    Join Date
    Sep 2005
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Steps for adding modules

    You need to build two functions in your module
    1. Function to configure module
    2. Function to do the module work

    Your admin panel can look in the "modules" directory for the filenames of all the modules and compare them against a database table of configured modules. Once a module is "activated", create a record in the configuration table with the filename as the modulename. Then display a link next to the module name. When this link is clicked, you'll "include()" the file and call the configure_modulename() function (each module is going to need a different name for it's functions so you use the module/filename plus the word config to distinguish it). The configure function will display the form of options to configure the module. The config function can now write it's config options to the database including what type of module it is (so the program knows when to call it).

    Now, in your program, you load all the modules that are active and call those modules based on the type of module. The module function needs to be unique so you should call it something like do_modulename (substitute the real modulename).

    You can expand from here.

    Good luck.
    PHP Shopping Cart Software Easy Ecommerce Shopping Cart Script.
    PHP Super Cart is 100% template driven.

  3. #3
    Resident Code Monkey Chris Corbyn's Avatar
    Join Date
    Nov 2005
    Location
    Melbourne, Australia
    Posts
    713
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Read up on these patterns:

    The strategy patterns
    The observer pattern
    The decorator pattern


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •