Transcript
Page 1: Drupal is Stupid (But I Love It Anyway)

Drupal is Stupid(But I Love It Anyway)

Thursday, November 10, 11

Page 2: Drupal is Stupid (But I Love It Anyway)

oh hai

• Brock Boland, Jackson River

• @brock

[email protected]

• GoSpringboard.com

Thursday, November 10, 11

Page 3: Drupal is Stupid (But I Love It Anyway)

Plan

• Drupal Overview

• What sucks

• What’s awesome

Thursday, November 10, 11

Page 4: Drupal is Stupid (But I Love It Anyway)

Drupal

• Open Source CMS

• 6 vs. 7

• Hook system

• Theme functions

• Contrib modules

Thursday, November 10, 11

Page 5: Drupal is Stupid (But I Love It Anyway)

Stupid

Thursday, November 10, 11

Page 6: Drupal is Stupid (But I Love It Anyway)

Core doesn’t do much

Thursday, November 10, 11

Page 7: Drupal is Stupid (But I Love It Anyway)

Animal Fun Fact #1

Thursday, November 10, 11

Page 8: Drupal is Stupid (But I Love It Anyway)

Animal Fun Fact #1

Source: http://blogs.dixcdn.com/shine_a_light/2011/02/02/love-birds/

Thursday, November 10, 11

Page 9: Drupal is Stupid (But I Love It Anyway)

Catch-all Hooks• hook_block()

• list, configure, save, view

• hook_taxonomy()

• delete, insert, update

• hook_comment()

• insert, update, view, validate, publish, unpublish, delete

• hook_nodeapi()

• alter, delete, delete revision, insert, load, prepare, print, rss item, search result, presave, update, update index, validate, view

Thursday, November 10, 11

Page 10: Drupal is Stupid (But I Love It Anyway)

No Objects

Thursday, November 10, 11

Page 11: Drupal is Stupid (But I Love It Anyway)

DB Layer

• Uses straight SQL queries

• db_query() and db_query_range()

• db_fetch_object() or db_fetch_array()

• drupal_write_record()

Thursday, November 10, 11

Page 12: Drupal is Stupid (But I Love It Anyway)

db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type);

D6

$fields = array( 'type' => (string) $type->type, 'name' => (string) $type->name, 'base' => (string) $type->base, 'has_title' => (int) $type->has_title, 'title_label' => (string) $type->title_label, 'description' => (string) $type->description, 'help' => (string) $type->help, 'custom' => (int) $type->custom, 'modified' => (int) $type->modified, 'locked' => (int) $type->locked, 'disabled' => (int) $type->disabled, 'module' => $type->module, );

if ($is_existing) { db_update('node_type') ->fields($fields) ->condition('type', $existing_type) ->execute();

if (!empty($type->old_type) && $type->old_type != $type->type) { field_attach_rename_bundle('node', $type->old_type, $type->type); } module_invoke_all('node_type_update', $type); $status = SAVED_UPDATED; }

else { $fields['orig_type'] = (string) $type->orig_type; db_insert('node_type') ->fields($fields) ->execute();

field_attach_create_bundle('node', $type->type);

module_invoke_all('node_type_insert', $type); $status = SAVED_NEW; }

D7

Thursday, November 10, 11

Page 13: Drupal is Stupid (But I Love It Anyway)

Source: http://schoolworkhelper.net/2011/06/wolves-habitat-characteristics-behaviors/

Animal Fun Fact #2

Thursday, November 10, 11

Page 14: Drupal is Stupid (But I Love It Anyway)

Animal Fun Fact #2

Source: http://www.indyposted.com/135755/sarah-palin-hunting-clip-offends-some-over-animal-abuse-others-over-poor-hunting-skills-video/sarah-palin-hunting-2/

Thursday, November 10, 11

Page 15: Drupal is Stupid (But I Love It Anyway)

Multiple Implementation

Options

Thursday, November 10, 11

Page 16: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 17: Drupal is Stupid (But I Love It Anyway)

Ajax/AHAH

Thursday, November 10, 11

Page 18: Drupal is Stupid (But I Love It Anyway)

function ahah_callback_method() { // AHAH processing prep $form_state = array('storage' => NULL, 'submitted' => FALSE); $form_build_id = $_POST['form_build_id']; $form = form_get_cache($form_build_id, $form_state);

$args = $form['#parameters']; $form_id = array_shift($args); $form_state['post'] = $form['#post'] = $_POST; $form['#programmed'] = $form['#redirect'] = FALSE;

drupal_process_form($form_id, $form, $form_state); $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

// Now you can do stuff}

DIY

Thursday, November 10, 11

Page 19: Drupal is Stupid (But I Love It Anyway)

/** * Given a POST of a Drupal form (with both a form_build_id set), this * function rebuilds the form and then only renders the given form item. If no * form item is given, the entire form is rendered. * * Is used directly in a menu callback in ahah_helper's sole menu item. Can * also be used in more advanced menu callbacks, for example to render * multiple form items of the same form and return them separately. * * @param $parents */function ahah_helper_render($form_item_to_render = FALSE) { $form_state = array('storage' => NULL, 'submitted' => FALSE); $form_build_id = $_POST['form_build_id'];

// Get the form from the cache. $form = form_get_cache($form_build_id, $form_state); $args = $form['#parameters']; $form_id = array_shift($args);

// Are we on the node form? $node_form = FALSE; if (preg_match('/_node_form$/', $form_id)) { $node_form = TRUE; module_load_include('inc', 'node', 'node.pages'); }

// We will run some of the submit handlers so we need to disable redirecting. $form['#redirect'] = FALSE; // We need to process the form, prepare for that by setting a few internals // variables. $form['#post'] = $_POST; $form['#programmed'] = FALSE; $form_state['post'] = $_POST;

// $form_state['storage']['#ahah_helper']['file'] has been set, to know // which file should be loaded. This is necessary because we'll use the form // definition itself rather than the cached $form. if (isset($form_state['storage']['#ahah_helper']['file'])) { require_once($form_state['storage']['#ahah_helper']['file']); }

// If the form is being rebuilt due to something else than a pressed button, // e.g. a select that was changed, then $_POST['op'] will be empty. As a // result, Forms API won't be able to detect any pressed buttons. Eventually // it will call _form_builder_ie_cleanup(), which will automatically, yet // inappropriately assign the first in the form as the clicked button. The // reasoning is that since the form has been submitted, a button surely must // have been clicked. This is of course an invalid reasoning in the context // of AHAH forms. // To work around this, we *always* set $form_state['submitted'] to true, // this will prevent _form_builder_ie_cleanup() from assigning a wrong // button. When a button is pressed (thus $_POST['op'] is set), then this // button will still set $form_state['submitted'],

// $form_state['submit_handlers'] and $form_state['validate_handlers']. // This problem does not exist when AHAH is disabled, because then the // assumption is true, and then you generally provide a button as an // alternative to the AHAH behavior. $form_state['submitted'] = TRUE; // Continued from the above: when an AHAH update of the form is triggered // without using a button, you generally don't want any validation to kick // in. A typical example is adding new fields, possibly even required ones. // You don't want errors to be thrown at the user until they actually submit // their values. (Well, actually you want to be smart about this: sometimes // you do want instant validation, but that's an even bigger pain to solve // here so I'll leave that for later…) if (!isset($_POST['op'])) { // For the default "{$form_id}_validate" and "{$form_id}_submit" handlers. $form['#validate'] = NULL; $form['#submit'] = NULL; // For customly set #validate and #submit handlers. $form_state['submit_handlers'] = NULL; $form_state['validate_handlers'] = NULL; // Disable #required and #element_validate validation. _ahah_helper_disable_validation($form); }

// Build, validate and if possible, submit the form. drupal_process_form($form_id, $form, $form_state); if ($node_form) { // get the node from the submitted values $node = node_form_submit_build_node($form, $form_state);

// hack to stop taxonomy from resetting when the form is rebuilt $form_state['node']['taxonomy'] = taxonomy_preview_terms($node); }

// This call recreates the form relying solely on the form_state that the // drupal_process_form set up. //$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

// Get the form item we want to render. $form_item = _ahah_helper_get_form_item($form, $form_item_to_render);

// Get the JS settings so we can merge them. $javascript = drupal_add_js(NULL, NULL, 'header'); $settings = call_user_func_array('array_merge_recursive', $javascript['setting']);

drupal_json(array( 'status' => TRUE, 'data' => theme('status_messages') . drupal_render($form_item), 'settings' => array('ahah' => $settings['ahah']), ));}

ahah_helper module

Thursday, November 10, 11

Page 20: Drupal is Stupid (But I Love It Anyway)

Assumes You Want an HTML Page

Thursday, November 10, 11

Page 21: Drupal is Stupid (But I Love It Anyway)

Source: http://www.dailymail.co.uk/travel/article-1320804/Mountain-goats-climb-160ft-near-vertical-Cingino-dam.html

Animal Fun Fact #3

Thursday, November 10, 11

Page 22: Drupal is Stupid (But I Love It Anyway)

Source: http://www.dailymail.co.uk/travel/article-1320804/Mountain-goats-climb-160ft-near-vertical-Cingino-dam.html

Animal Fun Fact #3

Thursday, November 10, 11

Page 23: Drupal is Stupid (But I Love It Anyway)

Steep Learning Curve

Thursday, November 10, 11

Page 24: Drupal is Stupid (But I Love It Anyway)

Original source unknown

Thursday, November 10, 11

Page 25: Drupal is Stupid (But I Love It Anyway)

Wonky-ass Interface

Thursday, November 10, 11

Page 26: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 27: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 28: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 29: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 30: Drupal is Stupid (But I Love It Anyway)

Always NeedCustom Module(s)

Thursday, November 10, 11

Page 31: Drupal is Stupid (But I Love It Anyway)

Media Handling

Thursday, November 10, 11

Page 32: Drupal is Stupid (But I Love It Anyway)

Thursday, November 10, 11

Page 33: Drupal is Stupid (But I Love It Anyway)

Misc. Crap

• HTML5

• Mobile

• Configuration Management

• Content Migration

Thursday, November 10, 11

Page 34: Drupal is Stupid (But I Love It Anyway)

Still?Pretty Awesome

Thursday, November 10, 11

Page 35: Drupal is Stupid (But I Love It Anyway)

Stable

Thursday, November 10, 11

Page 36: Drupal is Stupid (But I Love It Anyway)

Secure

Thursday, November 10, 11

Page 37: Drupal is Stupid (But I Love It Anyway)

Contrib Modules

Thursday, November 10, 11

Page 38: Drupal is Stupid (But I Love It Anyway)

Community

Thursday, November 10, 11

Page 39: Drupal is Stupid (But I Love It Anyway)

On the Whole?

• Stupid

• Getting better

• Still not going to use anything else

Thursday, November 10, 11

Page 40: Drupal is Stupid (But I Love It Anyway)

Questions?Which is funnier:

Pirate Monkey, or Aviator Monkey?

jacksonriver.com/monkeys

Thursday, November 10, 11

Page 41: Drupal is Stupid (But I Love It Anyway)

Once more

• Brock Boland

• @brock

[email protected]

Thursday, November 10, 11


Top Related