我是 Drupal 的新手,我想在我的块菜单中添加一个注销链接。在我的template.php中,我添加了这个:
function mytheme_preprocess_page(&$vars) {
global $user;
if ($user->uid != 0) {
// code for the account and logout links
$vars['block-menu-institutionnel']['account-link'] = Array (
'attributes' => Array('title' => 'Account link'),
'href' => '?q=user',
'title' => t('Account')
);
$vars['block-menu-institutionnel']['logout-link'] = Array (
'attributes' => Array('title' => 'Logout link'),
'href' => 'logout',
'title' => t('Logout')
);
}
else {
$vars['block-menu-institutionnel']['login-link'] = Array (
'attributes' => Array('title' => 'Login link'),
'href' => '?q=user',
'title' => t('Login')
);
}
}
但是,它不起作用,我不确定那block-menu-institutionnel
是真正的课程。这是我用 Firebug 检查块时得到的:
<div role="navigation" class="block block-menu contextual-links-region
no-title even block-count-2 block-region-header
block-menu-institutionnel" id="block-menu-menu-institutionnel"><div
class="block-inner clearfix"> <div class="block-content content"><ul
class="menu clearfix"><li class="first leaf menu-depth-1
menu-item-1104">...