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

All your Modules Belong to MySQL - 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

Modules get loaded into the database just like the plug-ins do. In the database you have two tables -- modules and module_status:

  • The modules table contains the same things that the plugins table does (only for the modules instead of the plug-ins) with one slight difference -- we’ve dropped the priority field and added a field for plugin_ID.
  • The module_status table is just like the plugin_status table; it contains the mod_ID which corresponds to the mod_ID in the modules table and the mod_status field. The mod_status field is also one of two values, “initialized” or “not_initialized”. Just like the plug-ins, these values tell the module loader to either load the module or not to load it.

When installing modules, start first with the modules table, put the module name in the mod_name field, and then put the directory that holds the modules in the mod_dir field. Once again this is the name of the directory that will hold the modules, beyond the plug-in directory. Then you need to fill in the mod_file with the name of the PHP file that makes up the module. Here’s a small example if you’ve forgotten the third article.

Let’s say you have a module in the following directory,

ROOT/plugins/foo_plugin/modules/bar.mod.php

Then the mod_dir would be “modules” and the mod_file would be “bar”. The reason we want it to be like this instead of the way we did it with the plug-ins is because it makes it easier for us to make multiple modules that use the same plug-in.

After you have the location set up, you’ll need to put in the plugin_ID of the plug-in that the module depends on. For example, if you have a plug-in named foo_plugin with a plugin_ID of 2, and the module bar.mod.php depends on foo_plugin to work. Then you’d put 2 in the plugin_ID field of the modules table for the bar.mod.php module. After that’s all done, you can fill in your optional fields which are mod_author, and mod_version, if you’d like.

Now in the module_status table, once again we need to put in the mod_ID which is an auto incrementing field in the modules table and is generated when we install a new module. Then we need to set the mod_status to either initialized or not_initialized depending on if you want it to load or not.



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