Home arrow PHP arrow Page 2 - Building a Site Engine with PHP, Part 5

Plug it in, Plug it in! - PHP

So you want to use your site engine that you’ve been working on? Okay, now is the time for me to show you how to add plug-ins, modules, blocks, and templates to your database so that they will work with your engine. It’s not that hard to do, and with just a few simple steps, you’ll be running your site off your new stylish site engine in no time.

TABLE OF CONTENTS:
  1. Building a Site Engine with PHP, Part 5
  2. Plug it in, Plug it in!
  3. All your Modules Belong to MySQL
  4. Improve your Blocking Skills
  5. Build your very own Theme Park!
By: James Murray
Rating: starstarstarstarstar / 32
July 19, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Once you’ve got a GUI for MySQL (unless you plan on going all out commando with it and using the command line), you can start with your plug-ins. Since everything depends on the plug-ins, I’d say you have to start with the plug-ins, but it is your choice.

In the database there are two tables for the plug-ins -- the plugins table and the plugin_status table:

  • The plugins table contains all the information about where the plug-ins are located, their ID’s, what they are named and their loading priority. It also has a few optional fields that contain the author’s name and the plug-in’s version.
  • The plugin_status table only contains two fields, neither of which is optional. The first one is the plugin_ID which corresponds to the plugin_ID in the plugins table, and the plugin_status field. The plug-in_status field is one of two values, “initialized” or “not_initialized”. These values tell the plug-in loader to either load the plug-in or not to load it.

The first thing you need to do when installing a plug-in is name it in the plugin_name field in the database; it can be anything you want it to be. The name of the plug-ins has nothing to do with the functionality of the site engine at all; it’s only for your personal reference. Then put in the name of the directory that the folder for the plug-in can be found in. If you followed the suggested directory structure outlined in article three, you’d put “plugins” in this field named plugin_dir. Then you need to put the name of the plug-in’s folder in the plugin_file field; for simplicity sake we just use the name of the folder that contains the plug-in as the plug-in file. If you remember back to the second article, we did this because it’s better for organizing and loading the plug-ins and we just names the PHP file for the plug-in main.plug.php. After that you have the plugin_priority field, this tells the engine if there’s any plug-ins that need to be loaded before others. The higher the number, the sooner it’s loaded.

For example if you have plugin1 with a priority of 0, plugin2 with a priority of 2, and plugin3 with a priority of 1, they will be loaded in the following order.

plugin2

plugin3

plugin1

As for the plugin_author, you can put in your name, or the name of the person that made the plug-in, or you can be like me and completely leave it blank. You can do the same thing for the plugin_version field.

In the plugin_status table, you have to add a row that contains the plugin_ID that is the same as the plugin_ID in the plugins table, which is auto incremented when you add your new plug-in. Then you have to tell it to either set the plug-in as initialized or not_initialized in the plugin_status field. Keep in mind if you set it to “not_initialized” the engine will not load it.



 
 
>>> More PHP Articles          >>> More By James Murray
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: