Drupal 7 notes for beginners

Not sure if this is really a question, but maybe I can give you some useful hints anyway.

First, you mentioned that you are familiar with MVC frameworks in the other question. So, here is the first point. Drupal is *not* a MVC framework. It is a CMS (some also use the term CMF for Content Management Framework) and it [roughly follows the PAC design principle.][1] This means that there can be rather big differences for doing X in a MVC framework and doing it in Drupal.

Second, Drupal is a *large* and rather complex project. It can do a lot for you out of the box, but to get to do *exactly* what you want, you will have to learn quite a lot. The [documentation][2] is usually very good (not for no reason, there is a dedicated documentation team that is working hard to improve it constantly) but you will have to read more than a single page in most cases to understand a single hook or function. Start with the linked components on the front page.

For hooks, they are in general a rather simple thing to understand. However, each hook either gets or needs to return specific arguments, which you need to understand too. Here are a two tidbits of information that might you help to better understand them.

- First, Drupal 7 caches hook implementations. That means when you add a new hook to your module, you need to clear the caches. This is what might have bitten you here. See http://drupal.stackexchange.com/questions/100/what-method-is-used-to-clear-caches-in-the-drupal for quick ways to do that.

- Then, there are really two groups of hooks. Normal hooks and alter hooks. Normal hooks usually *create* something (blocks, menus, permissions, ..). Alter hooks always end with an _alter() and are used to *change* something already created by another module. Your linked example hook is an alter hook. So for an alter hook, you also need to understand the part of Drupal that this hook touches. In this case, you need to understand how to create forms in Drupal before you can alter them.

As pointed out by rfay in your other question, he maintains the [Examples project][3] which contains a large number of simple, very well documented example modules for pretty much everything you can do in Drupal.

You can also always ask questions (try to only ask a single question at once, you will get better answers) here on Drupal Answers.


  [1]: http://www.garfieldtech.com/blog/mvc-vs-pac
  [2]: http://api.drupal.org/
  [3]: http://drupal.org/project/examples

Comments

Popular posts from this blog

create pdf by using javascript

yii framework simple shopping cart tutorial for beginners

yii2 arrayhelper::map vs array_map