At first, it can be hard to maintain and update your custom module but when you understand how it works, it’s pretty easy.
In your module.install file you will create a function for each update you want to make, for example, you forgot to add an agenda field in your content type :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
function custommodule_update_7001(&$sandbox) { $t = get_t(); field_create_field(array( 'field_name' => 'custom_date_agenda', 'type' => 'datetime', 'module' => 'date', 'active' => '1', 'cardinality' => '1', 'settings' => array( 'granularity' => array( 'month' => 'month', 'day' => 'day', 'hour' => 'hour', 'minute' => 'minute', 'second' => 'second', 'year' => 'year', ), 'tz_handling' => 'none', 'todate' => 'optional' ) ) ); field_create_instance(array( 'label' => $t('Date'), 'field_name' => 'custom_date_agenda', 'widget' => array( 'type' => 'date_popup', ), 'settings' => array( 'default_value_code' => '', 'default_value' => 'blank', 'default_value_code2' => '', 'default_value2' => 'blank' ), 'entity_type' => 'node', 'bundle' => 'custom_content_type', )); } |
Then, to update your module, just replace old files by the new ones. When you will run updates, Drupal will detect you were in version 7000 and will try to install the 7001 patch update. If you copy your module in a new Drupal installation and install it, the current version will be 7001 by default and the patch will be already installed automatically. You just need to increase this number each time you want to update your module. You won’t need to uninstall and install again your module each time you want to update it !
Recent Comments