You are here

Think in Drupal 7, 区块更多链接

g089h515r806 的头像
Submitted by g089h515r806 on 星期三, 2011-08-31 15:34

info文件:

name = Block More Link
description = Provide a more link for all blocks.
package = Other
version = VERSION
core = 7.x
configure = admin/config/block/morelink

install文件:

<?php

/**
 * @file
 * Install, update and uninstall functions for the block_morelink module.
 */

/**
 * Implements hook_schema().
 */
function block_morelink_schema() {
  $schema['block_morelink'] = array(
    'description' => 'Stores more link path.',
    'fields' => array(
      'module' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => "The block's origin module, from {block}.module.",
      ),
      'delta' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => "The block's unique delta within module, from {block}.delta.",
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => "The more link url of a block.",
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => "The more link title of a block.",
      ),
    ),
    'primary key' => array('module', 'delta'),
    'indexes' => array(
      'url' => array('url'),
    ),
  );
  return $schema;
}

/**
 * change 'primary key' to array('module', 'delta').
 */
function block_morelink_update_7000(&$sandbox) {
  db_drop_primary_key('block_morelink');
  db_add_primary_key('block_morelink', array('module', 'delta'));
}