You are here

Using UUID and UUID_FEATURES modules Part 1

Features is a great module in Drupal. One of the best things about this module is that it allows content to be imported/exported between sites. It makes Drupal development much easier, and more module developers are developing their modules with it in mind. To make the module compatible with the import/export features, one step is to generate an identity string value for each exportable entity. Maintaining these kinds of values is not easy. Fortunately, uuid and uuid_features are simple yet powerful modules created to help you in this situation. Below are the steps on how to use it.

Step 1: In the module install file, include a table definition in hook_schema generated by uuid_table_schema function function MODULE_NAME_schema() { return array( 'uuid_term_data' => uuid_table_schema('term_data', 'tid'), // 'uuid_TABLE_NAME' => uuid_table_schema('TABLE_NAME', 'NAME_OF_KEY_FIELD'), ); } /** TABLE_NAME: The actual entity table name, for example, taxonomy is term_data NAME_OF_KEY_FIELD: Name of the key field that uuid value was generated for, for example, taxonomy data table is tid **/

Step 2: To generate a new identity value for a new SEARIAL_ID_VALUE in your entry table you are going to export, simply call uuid_set_uuid(‘TABLE_NAME’,’IDENTITY_FIELD_NAME’, SEARIAL_ID_VALUE) Later on, when you need this identity value again, just call uuid_get_uuid(‘TABLE_NAME’,’IDENTITY_FIELD_NAME’, SEARIAL_ID_VALUE) And that’s it!

Appnovation Technologies