我自己写了个模块,开启之后,在区块中能找到它,也能对他进行配置,但是主页上却不显示,还请高手指点。下面是代码
<?php function user_navigation_block_info() { $blocks['user_navigation'] = array( 'info' => t('user navigation'), 'cache' => DRUPAL_CACHE_PER_ROLE, ); return $blocks; } function user_navigation_block_configure($delta = '') { $form = array(); if ($delta == 'user_navigation') { $form['user_navigation_string'] = array( '#type' => 'textfield', '#title' => t('Hello Label'), '#size' => 60, '#description' => t('This text will appear before a user name, for example, Hello,Devin, Welcome Devin.'), '#default_value' => variable_get('user_navigation', t('Hello')), ); } return $form; } function user_navigation_block_save($delta = '', $edit = array()) { if ($delta == 'user_navigation') { variable_set('user_navigation_string', $edit['user_navigation_string']); } return; } function user_navigation_block_view($delta = '') { switch ($delta) { case 'user_navigation': $block['subject'] = t('user navigation'); $block['content'] = user_navigation_contents($delta); break; } return $block; } function user_navigation_contents($which_block) { switch ($which_block) { case 'user_navigation': return array('#markup' => _user_navigation_block_contents(),); } } function _user_navigation_block_contents(){ global $user; $links = array(); if($user->uid){ $links[] = l($user->name,'user/'.$user->uid, array('attributes'=>array('class'=>array('account')))); $links[] = l(t('Logout'),'user/logout', array('attributes'=>array('class'=>array('logout')))); } else { $links[] = l(t('Signup'),'user/login', array('attributes'=>array('class'=>array('register')))); $links[] = l(t('Login'),'user/login', array('attributes'=>array('class'=>array('login')))); } return theme('item_list', array('items' => $links));