I can't speak for WordPress's implementation, but in Drupal we have pluggable
modules by way of magically named functions.
A sort of over-simplified version would be:
/modules/foo/foo.module
/modules/bar/bar.module
Core system scans the modules directory (only when asked, not every page load)
and adds foo and bar to a database table. Then an admin page lets the
admin check on that they should both be loaded. On page request,
both .module files are loaded. Then at various times in the code, there is
something like this:
$return = module_invoke_all('myhookname', $somevar);
function module_invoke_all($hook) {
$args = func_get_args();
array_shift($args);
foreach (module_list() as $module) {
$function = $module .'_'. $hook;
if (function_exists($function)) {
$return[] = call_user_func_array($function, $args);
}
}
return $return;
}
And then there's a crapload of those calls, so you can hook into the page
process in a zillion places. It makes the system very flexible.
Before someone says that the above is slow because it's preloading all code,
you're right. :-) We actually just refactored our development version to do
a self-inspection and load files by function on demand, but I left that out
here for illustrative purposes.
http://www.garfieldtech.com/drupal-7-registry
On Friday 16 May 2008, Ryan S wrote:
Hey,
Have just started screwing around with wordpress and I must say... it has a
lot of really really nice bits and pieces... two of my favourites are
widgets and plugins... not a hundred percent certain exactly what the diff
is though! :)
Anyway, was thinking it would be a great way to program for my next
project... instead of jumping into the code again and again... write
specific code and throw the file into the directory... then it either gets
read and executed automatically or have a feature like WP where you have to
activate it... only problem is, i dont know where to begin... i did do a
little google searching and have a rough idea.. but would appreciate it if
YOU could give me some links or code that got you started... something that
was easy when you were beginning... something that lit that lightbulb in
your head when you read it...
Thanks in advance!
R
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it. -- Thomas
Jefferson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php