Drupal 7 开发内部培训资料, 分头诗人

block

drupal写一个block的过程

1.

hook_block_info(){

 $blocks['xxxx']=array(

    'info' => t('xxxx'),

    'cache' => DRUPAL_CACHE_GLOBAL,

  )

return $blocks;

}

 

2.

function xxxx_block_view($delta = '') {
  
  switch ($delta) {
    case 'xxxx':
      
      $block['subject'] = NULL;
     
      $block['content'] = xxxx_contents($delta);
      break;
  }
  return $block;
}

 

3.

function xxxx_contents($delta = '') {
  
  switch ($delta) {
    case 'xxxx':
    
      $add_xxxx_link = array(
        '#theme' => 'link',
        '#text' => t('xxxx'),
        '#path' => 'node/add/xxxx',
        '#options' => array(
          'attributes' => array(),
          'html' => FALSE,
         ),
      );
      return $add_xxxx_link;
  }
}
0
投票
1
回答
1660
查看
0
投票
4
回答
1318
查看

页面

订阅 RSS - block