How to extend and configure Drupal without user interaction or database dump By Damien Snoeck for...

Preview:

Citation preview

How to extend and configureDrupal without user interaction

or database dump

By Damien Snoeckfor Switzerland Romandy Drupal Group

January 27, 2010

Work done with Jeff Trudeau

Key Points

Pros and Cons

Development environment and tools

Custom modules

Features module

Pros and Cons

+ Ease the production server update

+ No database dump

+ No SQL diff

+ No core files in your code repository

+ Fast deployment

- Need a lot of more time !

Files Structure

Dev tools

Drush: command line toolsh tools/drush -c files/drushrc.php make files/Makefile drupal/

Drush Make: drush extensioncore = 6.x

projects[] = drupal

projects[drupal] = 6.15

# Advanced help

projects[] = advanced_help

projects[advanced_help][subdir] = "contrib"

projects[advanced_help][version] = 1.2

Drupal Install Script

1. Reset Environment

2. Download and extract drush and drush make

3. Run drush make to create environment

4. Create symbolic links between drupal~ and drupal

5. Apply local patches

6. Other initialization tasks

Custom Modules

Base module Define dependencies Setting Drupal variables Adding new language Use custom theme Enable/Disable default blocks Translation files *.fr.po

Comparison

1. Administer › User management › User settings › uncheck Require e-mail verification

2. Administer › Site configuration › Languages › Add language

3. Administer › Site Bulding › Theme › Enable theme

4. Administer › Site Bulding › Blocks › Configure a block

1. variable_set('user_email_verification', FALSE);

2. locale_add_language('fr', 'French', 'Français');

3. global $custom_theme; $custom_theme = 'mmio_base';

4. drupal_write_record('blocks', array('bid'=>18, 'pages'=>'admin*', visibility=>1), 'bid');

Custom Menu Module

Use of hook_menu()

$items['companies'] = array(

'title' => 'Companies',

'description' => 'List of companies',

'menu_name' => 'en-menu1',

'access arguments' => array('access content'),

'page callback' => 'companies',

'weight' => 0,

'options' => array(

'attributes' => array('title' => 'Companies'),

'langcode' => 'en'

),

'type' => MENU_NORMAL_ITEM,

'file' => 'mymodule_menu.inc.php',

);

Features Module

Can be exported as module: Content type (with image presets) Permissions Views Dependencies Feeds

Integration with Drush

Live Demo