Site maintainer (chx) comment: This is a duplicate post. Please continue discussion at the other post.
Posted this over in "How do I.." forum, not sure if there or this is the appropriate place, but will do this just to make sure I'm in the right place
Been studying and learning the Drupal internal codes so that I can contribute to Drupal eventually.
To be able to contribute sooner, I'm hoping that the Drupal experts who knows the internal very well can give me hints and pointers on how the internal works thus allowing me to understand and learn quicker.
I have been trying to follow the code starting with index.php and I see that first the bootstrap.php is loaded and the configuration file is included. After that, "drupal_page_header()" is called, and if caching is set, Drupal will serve the cached version of the page and set the HTTP header. (right so far?)
If cache are not enabled/available, then Drupal proceeds to set the header to current date and time and then include common.php which includes several files, set the Content type in the header, build its path and then loads all module with "hook_init" and then a "hook_exit" (right so far?)
The thing is, when I look into the module codes, I dont see the corresponding function for "hook_init" or "hook_exit"? Am I missing something here?
The modules I checked out for the init and exit hook calls are the following...
block
user
system
filter
node
page
story
watchdog
locale
and all of them dont have those init and exit hooks call.
Where in the codes does remaining hook calls are hooked into Drupal?
Where and when is the theme engine loaded to incorporated theme?
I feel like I am missing something here, I have been tracking down calls, trying to find out what each call does, how and why. I dont see specific calls being made for specific hooks except for "init" and "exit" and even those are not incorporated into the modules listed above.
I've been reading the API, reading through the forums, trying to find something that would cover the above questions, but dont see it, if you can tell me the links that covers the above, I would be happy to read it, and if not, then please give me pointers on how the Drupal internals work.
Thanks,
BlueDrupal
Comments
drupaldocs
Have you read this? http://drupaldocs.org/api/4.6
-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
Been at the DrupalDocs 4.6
Been there, I am not asking what functions is provided. If you will read my questions you will see that I am asking how Drupal works internally.
When a user first visit a Drupal-powered website, what does Drupal do first? Second? Third?
From what I could gathered by reading the source code, I see that Drupal check to see if there is anything cached, if so, serve that and exit. If there are nothing cached, then Drupal proceed to load modules. But thats all i see. Where does it load the theme engine?
Theme engine is not a module, per se, but I do not see anywhere in the code that loads the theme engine.
And if you will noticed, I also asked about the hooks call for "init" and "exit", I checked the modules provided and dont see those hook call in those modules. Made me wonder how the heck those modules are able to hook themself into Drupal. Anyone here know? I am curious about this part.
It will be helpful if you can point out a section of code that does what I am asking for, for example, in which page, which section of code does Drupal loads the theme engine?
I hope I am explaining it clearly
BlueDrupal
I'm no expert yet...
...but I think starting at index.php is the wrong place to figure Drupal out IMO.
I'd recommend starting out at the other end. eg make or customise a PHPTemplate based theme. You could try adding some smarts to it - eg conditionally show different interface bits based on criteria like role, module name or node type etc. Then you could start overriding module theming functions in your themes template.php file etc. There's a hell of a lot you can do just with making a theme as I'm quickly finding out.
After that you could try customising modules themselves, then work your way up to writing a module yourself to get a good idea of all the hooks etc.
Playing with themes and overriding module functions also gives you a more portable set of customisations - and makes it much easier to upgrade to new drupal versions as your changes are all concentrated in one area.
After you've done all that, then you could concentrate on figuring out the nitty gritty core stuff. It would be a much more accessible way of dipping your toes in the water and making meaningful changes, and by the time you start looking at the core you're in a much better position to understand it.
As I said, I'm pretty new to this myself and don't understand a whole lot yet either :)
Just grep it...
IANADD, but those two functions refer to hook points that modules can export, and thus they will be named e.g. throttle_exit for the throttle module, not hook_exit.
If you're on a Unix platform, I recommend familiarizing yourself with the grep command. It's very useful for searching through the entire source tree. For example, to locate hook_exit exports I did:
When I say hook_init or hook_exit
When I say hook_init or hook_exit, i meant it as any module implementing those function such that they are named module_init or module_exit. For example, the block module will implement hook_init or hook_exit as block_init or block_exit.
Now, when i read module codes, I do not see those module implementing those hooks and I am speaking of the main module that is needed by Drupal such as block, filter, system, user and watchdog.
I did not enable any other modules except those that are required by Drupal. I did this so that I can see how those core modules run and how are they hooking into Drupal without the "init" or "exit" hook. And I still dont understand how those core modules can be hooked into Drupal without having the "init"/"exit" function implemented.
BlueDrupal
internals
I think this is what you are looking for:
http://drupal.org/node/10858
As for the theme engine, theme.inc is loaded by common.inc and the theme itself is loaded the first time theme(..) is called.