Drupal development

From Things and Stuff Wiki
Revision as of 17:27, 11 September 2012 by Milk (talk | contribs) (→‎JavaScript)
Jump to navigation Jump to search


needs refactoring to work with theming

Basics

Architecture

  • Drupal dev docs - "Newcomers to Drupal development should read the conceptual information provided in the 'Components of Drupal' section, and then proceed to examine one of the heavily-documented example modules below. The examples are fully-functioning Drupal modules, so you can download them from the contributions repository and alter them as you experiment."

Modules

CLI

Coding

dpm()

Admin

Content

Module Admin

Coding

Patches

patch -p1 < path/file.patch

or

git apply path/file.patch

Hooks

"Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

"To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and calls that hook in all enabled modules that implement it."

Menu system (path)

Content

Entities

An entity is a kind of content stack. An entity base table is tied to fields using bundles. Entity types include node, comment, taxonomy term, user profile, organic group, etc. Entity types can allow bundling or not (creating types of node node vs. users, though see the Profile 2 module). Fields are used to store and display various data types, and can be reused across bundles and entities.

hook_entity_info - "Inform the base system and the Field API about one or more entity types."

Ctools

Forms

For beyond basic content types field layouts;

function milk_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'contact_node_form') {
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Send'),
    );
  }
}

Menus

JavaScript

Video

Adding a JS file

In theme .info;

scripts[] = scriptfile.js

Drupal Behaviours

jQuery

AJAX

JSON