How Drupal works? [closed]

2019-01-29 14:31发布

Could someone provide a architectural overview of the Drupal 7 control flow? Perhaps in the sense of a flowchart about how a page gets generated. What additional resources would you suggest consulting with regards to how Drupal works?

9条回答
Lonely孤独者°
2楼-- · 2019-01-29 15:28

It depends on how deep an understanding you're looking for; if you have a good knowledge of php, I would suggest reading through the code itself, starting with index.php, and then going on to the includes/bootstrap.inc, and then some of the other scripts in that directory.

The key include files:

  • menu.inc is very important to understanding how the overall system works, as it handles a lot of the implicit mapping of URLs to content.
  • common.inc has most of the otherwise-mysterious functions that form the basis of the API.
  • module.inc handles the hook invocations that Eaton mentioned
  • form.inc deals with form display, submission and processing
  • theme.inc handles presentation.

There's also some key functionality in the modules/ directory; in particular, modules/node/node.module forms the basis of the node system, which is in general what's used to encapsulate site content.

The code is, in general, very well-commented and clear. The use of Doxygen markup within the commenting means that the code effectively is the canonical documentation.

It also helps to do this using an editor that can quickly jump to the definition of a function. Using vim in combination with ctags works for me; you do have to tell ctags to index .inc, .module, etc. files as php files.

查看更多
Root(大扎)
3楼-- · 2019-01-29 15:28

New contributor here, 2 years late on the conversation ;-)

Replying to https://stackoverflow.com/a/1070325/1154755

To extend core functionality don't rewrite it. Instead copy the module into /sites/all/modules/ or /sites/[yoursite]/modules and extend THAT, or create a new module in those places. Same for themes.

Actually, I never had to copy a core module to update it. Drupal Hooks should be all you need.

For themes, yeah, sometimes it's the only way to go, but often, you can build a subtheme to get the result you need.

查看更多
走好不送
4楼-- · 2019-01-29 15:29

http://drupal.org/handbooks

Read the handbooks, especially the theme developer's guide. Drupal supports several theme engines. Zen uses phptemplate, so pay attention to that portion of the guide.

For module development, the API is documented at api.drupal.org.

specially when you need to get the info fast and fast http://www-128.ibm.com/developerworks/ibm/osource/implement.html

查看更多
登录 后发表回答