You are here

nodeorder.install in Node Order 8

Same filename and directory in other branches
  1. 5 nodeorder.install
  2. 6 nodeorder.install
  3. 7 nodeorder.install

Nodeorder install file.

File

nodeorder.install
View source
<?php

/**
 * @file
 * Nodeorder install file.
 */

/**
 * Implements hook_install().
 *
 * Adds field 'weight' to core table 'taxonomy_index'.
 *
 * @todo: Handle exceptions that could be thrown by DatabaseSchema::addField.
 */
function nodeorder_install() {

  // Define field properties.
  $spec = [
    'type' => 'int',
    'signed' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'initial' => 0,
    'description' => t('A user-defined weight for each node in its respective category.'),
  ];

  // Create an index for 'weight'.
  $keys['indexes'] = [
    'weight' => [
      'weight',
    ],
  ];
  $keys['fields']['weight'] = $spec;

  // Add the column to the table.
  db_add_field('taxonomy_index', 'weight', $spec, $keys);

  // Set the weight of the nodeorder module ensure that nodeorder can alter
  // forms after the taxonomy module.
  module_set_weight('nodeorder', 5);
}

/**
 * Implements hook_uninstall().
 *
 * Drops field 'weight' from core table 'taxonomy_index'.
 */
function nodeorder_uninstall() {
  db_drop_index('taxonomy_index', 'weight');
  db_drop_field('taxonomy_index', 'weight');
}

Functions

Namesort descending Description
nodeorder_install Implements hook_install().
nodeorder_uninstall Implements hook_uninstall().