alter / automatize the install process

in the .profile file of the install profile (here "mysnippet" profile)

  1. /**
  2.  * Implementation of hook_install_tasks_alter().
  3.  */
  4. function mysnippet_install_tasks_alter(&$tasks, $install_state) {
  5. // Database step.
  6. $tasks['install_settings_form'] = array('function' => 'my_install_settings_form');
  7. // Site configuration
  8. $tasks['install_configure_form'] = array('function' => 'my_install_configure_form');
  9. // Install is complete
  10. $tasks['install_finished'] = array('function' => 'my_install_finished');
  11. }
  12.  
  13. /**
  14.  * Alter database form settings
  15.  */
  16. function my_install_settings_form(&$install_state) {
  17. $form_state['storage']['database'] = array(
  18. 'database' => 'mysnippet',
  19. 'username' => 'myusername',
  20. 'password' => 'mypasswd',
  21. 'host' => 'localhost',
  22. 'port' => '',
  23. 'driver' => 'mysql',
  24. 'prefix' => ''
  25. );
  26. // call the initial submit
  27. install_settings_form_submit("", $form_state);
  28. }
  29.  
  30. /**
  31.  * Alter site configuration settings
  32.  */
  33. function my_install_configure_form(&$install_state) {
  34. $form_state['values'] = array(
  35. 'site_name' => $d['name'],
  36. 'site_mail' => 'no-reply@'.$d['name'].'.cec',
  37. // uid 1
  38. 'account' => array (
  39. 'name' => 'adminRTD',
  40. 'mail' => 'admin@'.$d['name'].'.cec',
  41. 'pass' => '07adminRTD73' //$d['default_admin_pass'],
  42. ),
  43. 'site_default_country' => 'BE',
  44. 'date_default_timezone' => 'Europe/Brussels',
  45. 'clean_url' => 1,
  46. 'update_status_module' => array (
  47. 1 => 0,
  48. 2 => 0
  49. )
  50. );
  51. }
  52.  
  53. /**
  54.  * Additional tasks when install is finished
  55.  */
  56. function my_install_finished(&$install_state) {
  57. variable_set('install_profile', drupal_get_profile());
  58. db_update('system')
  59. ->fields(array('weight' => 1000))
  60. ->condition('type', 'module')
  61. ->execute();
  62. drupal_get_schema(NULL, TRUE);
  63. }

Display errors - WSOD

The bootstrap override the values you could set to display error ad the reporting level. To be 100% sure everything is printed out when something fails in a blank screen (wsod), make index.php like this:

Properly render a field

Drupal offers a few (sometimes complicated...) solutions to output a field. Lets take an example with a date field.
To display the full rendered field: field_view_field()

Using once()

ensure ajax reload don't apply the behaviours for items already processed

Change the theme

Programmatically change the theme on runtime by implementing hook_custom_theme()

Manually clear caches

for views and panels

Add a Jquery ui library

get the library names to use in /misc/ui folder

Embed a custom page

Get the rendered output of a custom page created with page manager (ctools) module

Embed a mini panel

Get the html output of a mini-panel

alter / automatize the install process

in the .profile file of the install profile (here "mysnippet" profile)

Aegir: perform custom tasks after a new site is installed

in a custom module, in a file called mysnippet.drush.inc (keep in mind that the install process is handled by drush...)