You are here

function tabledrag_example_install in Examples for Developers 7

Same name and namespace in other branches
  1. 8 tabledrag_example/tabledrag_example.install \tabledrag_example_install()
  2. 3.x modules/tabledrag_example/tabledrag_example.install \tabledrag_example_install()

Implements hook_install().

This datafills the example item info which will be used in the example.

Related topics

File

tabledrag_example/tabledrag_example.install, line 84
Install and uninstall functions for the tabledrag example module.

Code

function tabledrag_example_install() {

  // Ensure translations don't break at install time.
  $t = get_t();

  // Insert some values into the database.
  $rows = array(
    array(
      'name' => $t('Item One'),
      'description' => $t('The first item'),
      'itemgroup' => $t('Group1'),
    ),
    array(
      'name' => $t('Item Two'),
      'description' => $t('The second item'),
      'itemgroup' => $t('Group1'),
    ),
    array(
      'name' => $t('Item Three'),
      'description' => $t('The third item'),
      'itemgroup' => $t('Group1'),
    ),
    array(
      'name' => $t('Item Four'),
      'description' => $t('The fourth item'),
      'itemgroup' => $t('Group2'),
    ),
    array(
      'name' => $t('Item Five'),
      'description' => $t('The fifth item'),
      'itemgroup' => $t('Group2'),
    ),
    array(
      'name' => $t('Item Six'),
      'description' => $t('The sixth item'),
      'itemgroup' => $t('Group2'),
    ),
    array(
      'name' => $t('Item Seven'),
      'description' => $t('The seventh item'),
      'itemgroup' => $t('Group3'),
    ),
    array(
      'name' => $t('A Root Node'),
      'description' => $t('This item cannot be nested under a parent item'),
      'itemgroup' => $t('Group3'),
    ),
    array(
      'name' => $t('A Leaf Item'),
      'description' => $t('This item cannot have child items'),
      'itemgroup' => $t('Group3'),
    ),
  );
  if (db_table_exists('tabledrag_example')) {
    foreach ($rows as $row) {
      db_insert('tabledrag_example')
        ->fields($row)
        ->execute();
    }
  }
}