hi i have created menu in drupal. i have added login and logout button in menu.but i want show login wh开发者_开发问答en user is not login and want to show logout when user is login.(both login and logout in one menu). i have created a block named as top menu. please tell me how can i add condtion in block.and which files i have to made the changes. or there is one method in my mind that i should make two blocks, one blocks have login andone block have logot. but i dont have any idea that how can i use this in if else condition
add this in your block
global $user;
if ( $user->uid ) {
// Logged in user show logout button
}
else {
// Not logged in show login button
}
Drupal6 is smart enough to only show the login menu item to users who are not logged in and logout to only the users who are logged in. Make one menu item with the path "user/login" and move the default logout menu item (from the navigation menu) to the menu you want.
精彩评论