Drupal development

From Things and Stuff Wiki
Revision as of 08:45, 15 November 2012 by Milk (talk | contribs) (→‎Forms)
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."

Multisite

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

Menus

JavaScript

Video

Adding a JS file

In theme .info;

scripts[] = scriptfile.js

In template.php;

drupal_add_js()
  first paramater path
  second paramater (goes through as 'type: ' array item, defaults to file)
    file, setting, inline, external
    default: preprocess: true, everypage: true, 
    weight:
$element['#attached']['js']

Drupal JS API and Behaviours

Drupal has an API for passing information between PHP and JS. Drupal.js sets up Drupal namespace.

Render Array

PHP sent by JSON to change content.

jQuery

AJAX

JSON