Tuesday, November 30, 2010

How does drupal works?

1. The web server picks the PHP file to run based on the URL That PHP file is (almost) always Drupal core's index.php
2. The PHP file runs. (index.php). It includes a bunch of include files which define helper functions and settings, it connects to the database (which is required) and pulls more settings out of the database, it includes even more files (themes and modules) which define yet more helper functions and callbacks, and finally it decides which function, in all of the combined tens of included files that should be run
3. It calls that function, which is called a "menu callback". This "menu callback" is the first chance that you have to run your own code.
4. Your menu callback runs. It can optionally call PHP standard library functions, include other PHP files for extra functionality, or call any Drupal standard library functions.
5. As the menu callback runs, anything that it outputs is sent to the browser, just like in the raw PHP file case above.
6. But the Drupal Way is for the menu callback to return a string. That string then gets plugged into a template page for the site (which is one component of a theme), and the template page with the string plugged into the right spot gets sent back to the browser.

No comments:

Post a Comment