Future-ProofYour Drupal 7 Site – About Me – Objectives



Future-ProofYour Drupal 7 Site – About Me – Objectives

0 0


2014-06-04

Future-Proof your Drupal 7 Site - DrupalCon Austin 2014

On Github davereid / 2014-06-04

Future-ProofYour Drupal 7 Site

DrupalCon Austin 2014

Dave Reid / @davereid

davereid.github.io/2014-06-04

About Me

Senior Developer at Lullabot

Twitter: @davereid

IRC: davereid

Maintain amost 2% of contrib modules

Core subsystem maintainer

Father of two cats and one boy

Objectives

For your site buildersand architects to makeinformed choices now

Ease pain of site userswhen switching to Drupal 8

User Interface

Spark Distribution

Navbar

Inline Editing

https://drupal.org/project/quickedit

Official WYSIWYG: CKEditor

Responsive Bartik

https://drupal.org/project/responsive_bartik

HTML5

VIEWS IN CORE!

https://drupal.org/project/views

Administration Views

https://drupal.org/project/admin_views

Views Bulk Operations (light)

https://drupal.org/project/views_bulk_operations

Views Responsive Grid

Responsive Tables

Breakpoints

Responsive Pictures

Tours

Module page filtering

https://drupal.org/project/instantfilter

Simplified Menu Administration

https://drupal.org/project/simplified_menu_admin

Escape Admin

Caption Filter

https://drupal.org/project/caption_filter

<img data-align="center" data-caption="Test caption" ... />

Custom blocks (Bean)

https://drupal.org/project/bean

Reusable blocks: MultiBlock

https://drupal.org/project/multiblock

Field types

Entity reference

NOT Node or User reference modules

Telephone

NOT phone module

Email (lite)

URL

NOT link module

Datetime (Date lite)

https://drupal.org/project/date

Use the Date (ISO format) field type. Not the Date or Date (Unix timestamp) field types.

For developers

Libraries
APIs and Plugins

Composer

For managing external auto-loadable (PSR-0/4) libraries

https://getcomposer.org

Composer

sites/all/composer.json

{
    "require": {
        "fale/isbn": "1.x-dev"
    }
}

Run composer install

// Make the sites/all/vendor libraries autoloadable.
require_once DRUPAL_ROOT . '/sites/all/vendor/autoload.php';

$result = \Isbn\Check::is10($isbn);
        

https://drupal.org/project/composer_vendor

https://drupal.org/project/composer_manager

API and Plugins

Many ways to do the same thing in Drupal 7.

Hooks

/**
 * Implements hook_mymodule_hook_info().
 */
function example_mymodule_hook_info() {
  $info['example'] = array(
    'label' => t('Example implementation'),
    'callback' => 'example_mymodule_callback',
    'settings form' => 'example_mymodule_form',
  );
  return $info;
}

CTools plugins

function example_ctools_plugin_directory($module, $plugin) {
  if ($module == 'mymodule' && $plugin == 'hook') {
    return "plugins/$module/$plugin";
  }
}

// plugins/example/hook/example_implementation.inc
$plugin = array(
  'title' => t('Example implementation'),
  'class' => 'ExampleMyModuleHookImplementation',
);

// plugins/example/hook/ExampleImplementation.class.php
class ExampleMyModuleHookImplementation {
  // Does stuff.
}

Plugins in D7

lib/MyModuleHookPluginInterface.php
class MyModuleHookPluginInterface {
  public static function getInstance($config = array());
  public function getDefaults();
  public function process($config);
}
lib/MyModuleHookPluginBase.php
abstract class MyModuleHookPluginBase extends MyModuleHookPluginInterface {
  public funciton getInstnace($config = array()) {
    $class = get_called_class();
    return new $class($config);
  }

  public function getDefaults() {
    return array();
  }

  abstract public function process($config);
}

Plugins in D7

example.module
function example_mymodule_hook_info() {
  $info['example'] =
    'label' => t('Example implementation'),
    'class' => 'ExampleMyModuleHookPlugin',
  );
  return $info;
}
example.info
files[] = lib/ExampleMyModuleHookPlugin.php
lib/ExampleMyModuleHookPlugin.php
class ExampleMyModuleHookPlugin extends MyModuleHookPluginBase {
  public function process($config) {
    // Do stuff!
  }
}

The Other Stuff

Configurable view/display modes

https://drupal.org/project/entity_view_mode

CMI

Migrate is your friend

https://drupal.org/project/migrate

https://drupal.org/project/migrate_d2d

RESTful Web Services

https://drupal.org/project/restwsNOT services module

Translation

PSR-0 / PSR-4

https://drupal.org/project/xautoload

More More Things

phpunit
Symfony
Backbone
Underscore
Guzzle
JS local storage

Things you should probably stop using

We don't want no scrubs

Thank you!Questions?

Please rate this session at https://austin2014.drupal.org/session/future-proof-your-drupal-7-site