The understanding of Drupal "turn"

Source: Internet
Author: User
Tags drupal

Write this article is want to with just use Drupal friends, share a bit of experience, domestic with Drupal too little, I hope we can communicate well. Hopefully after a few minutes you'll be able to get started with Drupal, at least understand Hook,api,theme,module,cck,hack core

Don't make Drupal think complicated, everything can be inferred, even if you do not understand Drupal, you only need to understand a little basic PHP on the line. My previous article said, learning Drupal, to master the PHP Print_r, to understand the PHP array, now a little more, to be PHP's include file.

1.drupal is written in PHP, so PHP can do the Drupal can do, PHP can not do, Drupal of course not. 2.drupal is powerful, but the powerful explanation is difficult to get started with because of its mechanism. Two of them are crap.

3. You should see a lot of Drupal introduction (Wasting Time comparing Drupal and joomla,wordpress), you should have seen hook,api,theme,module,cck,hack core These keywords now, okay, to understand Drupal, the key to understand what is the module, the remaining few keywords are actually derived from the module understand the following sentence, you know Drupal PHP to run must *.php file it, Drupal is the same, PHP logic is very complex to separate a few php to write it, Pure PHP files When these php are combined with the use of include or require. Drupal is the same, but Drupal default include files are not *.php but *.module so as long as you put the content you want to run in *.module, Drupal will be able to go to the include, You don't have to write a word for yourself. Include Xxxx.module 4. But this *.module is a bit special, he almost only accepts function (Chinese is called functions.) in-depth also accept what, novice do not understand, So you can cram all of the functions you've written before into *.module, without renaming it (except for the same name as the existing Drupal function)

5. What is an API? All Drupal function is called API, so do not think the API is too complicated, because the API is *.module (and some include/*.inc files) function. However, the actual discussion often refers to Drupal built-in functions, but you have a different module, such as Cck,views, the internal functions of these modules you can also use, they are actually API.

6. What is hook, I just learn Drupal when also very do not want to see this word, afraid, feel very complex, finally once I have to understand the hook, I only found that, grandma's, so simple. Believe me, you write PHP, actually wrote countless "hook!": Hooks are also function, which is also placed in the module file, but the name of a particular point. The hook mechanism is a function called the B function automatically. You'll find that Drupal has a lot of functions like this: function Modulename_xxxx () {. Module_involve (xxxx);//I don't know if I'm mistaken.

To see this thing is to define a hook, that you are in a *.module if you define a function by the name of Drupal, the functions above will be executed automatically as soon as they are executed.

7.Drupal has a lot of intrinsic functions, which are called by default at startup, so you just have to add your own logic to run in those functions that are bound to run, isn't it a hook? Of course, this is called hack core, compare dirty, So Drupal added an egg called module mechanism to tell everyone: you just follow certain naming rules to do things, you don't have to hack core every time! So actually Hook,api,hack core is just that .

8. For example, the most commonly used hook_nodeapi, which means that when Drupal is about to display an article, the HOOK_NODEAPI function will be executed! So then you have to think that your function can be executed, either directly or whatever you find the original function of Hook_nodeapi, Copy your code directly, or define a function called Xxxname_nodeapi by the Drupal naming convention. So simple, you create an API, and you create a moduel Drupal mechanism you understand half!

9.drupal tries (in fact) to run all requests with a index.php in a root directory, so you know with your butt that your logic (code) must be able to run and be referenced by this index.php (include or require). So hemp, You don't want to figure out how Drupal works, just index.php on this one. This is where my drupal ideas come from.

Finally: What do you want to understand drupal why XXX, do not think of Drupal, think if you write PHP yourself, you will do, think you will understand the mechanism of Drupal, even if almost not too much. The extrapolate of the Chinese is always invincible!

Http://www.trackself.com/archives/1611.html

The understanding of Drupal "turn"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.