1

Ok, this is a newbie-question i'm afraid to ask for some time .. how to use Drupal Hooks? Yes, i know where to look for the code, but then? Put it in the template-folder, a block, a custom module?

When i google for a tutorial, the most results are for Drupal 6 / before 2010.

  • Yes google can answer a lot of questions, but if really want to know how something works always look for documentation. api.drupal.org/api/drupal is not a waste of web storage, please give some credit who woks to maintain this doc. – Vagner Mar 2 '16 at 12:53
0

Drupal Hooks are a call back mechanism, you name your function modulename_Hook like mymodule_form_alter(). Based on the name of the function, it is called in the proper phase of the Drupal execution. This is an entry point from Drupal into your module.

Using Drupal Hooks doesn't change that much from version to version, the hooks that are available do change from version to version. The old tutorials are still good. The best way to learn how to use hooks is to examine existing contributed modules, or that's what worked for me. Hooks you really need to learn, or that you should start with are the FORM API hooks hook_form_alter, hook_form, hook_form_validate (https://api.drupal.org/api/drupal/includes!form.inc/function/drupal_form_submit/7), ..., hook_menu is generally needed if you're adding a page to the website.

If you can get a copy of "Pro Drupal Development" or "Pro Drupal 7 Development" (http://www.drupalbook.com/ or http://www.amazon.com/Drupal-Development-Experts-Voice-Source/dp/1430228385) it might help as well. Go with the pdf downloads. There are also 2 or 3 day classes you can take, or you can get training at your local Drupal Camp or Drupal convention.

  • Since chx answered the original question, I suggest that you use that answer. chx is quite a respected member of the Drupal community. – pacmaninbw Mar 2 '16 at 13:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.