PHP Drupal hook_block 6.x

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Drupal hook_block 6.x相关的知识,希望对你有一定的参考价值。

<?php

function hook_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {

    case 'list':
      $blocks[0]['info'] = t('Block 1');
      $blocks[1]['info'] = t('Block 2');
      return $blocks;

    case 'configure':
      if ($delta == 0 && user_access('administer module')) {
        $form['module_block_1'] = array();
      }
      if ($delta == 1 && user_access('administer module')) {
        $form['module_block_2'] = array();
      }
      return $form;

    case 'save':
      if ($delta == 0) {
        variable_set('module_block_setting_1', $edit['module_block_1']);
      }
      if ($delta == 1) {
        variable_set('module_block_setting_2', $edit['module_block_2']);
      }
      break;

    case 'view':
      if ($delta == 0) {
        $block['subject'] = t('Block 1 title');
        $block['content'] = t('Block 1 content');
      }
      if ($delta == 1) {
        $block['subject'] = t('Block 2 title');
        $block['content'] = t('Block 2 content');
      }

      return $block;
  }    
}

以上是关于PHP Drupal hook_block 6.x的主要内容,如果未能解决你的问题,请参考以下文章

PHP hook_views_post_render Drupal 6.x

PHP 主题主链接Drupal 6.x添加跨度和有用的ID

PHP hook_views_query_alter Drupal 6.x(substring)

Drupal钩形块6.x

钩子视图预渲染Drupal 6.x

Drupal 6.x中的hooku viewsu postu render