Drupal development

From Things and Stuff Wiki
Revision as of 01:32, 13 February 2012 by Milk (talk | contribs) (→‎Themes)
Jump to navigation Jump to search


Basics

  • 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."

Content architecture

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."

Themes

Templates

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'),
    );
  }
}

JavaScript

<?php
  drupal_add_js(drupal_get_path('theme', 'mytheme') .'/my_js_file.js', 'theme');
?>