logo       

RE: Navigation Menu Only for Admin?: msg#00062

php.drupal.support

Subject: RE: Navigation Menu Only for Admin?

> Make a custom PHP block with the following code:
>
> global $user;
> if ($user->uid == 1) {
> return '<div class="menu">'. theme('menu_tree') .'</div>';
> }


Hi Steven,

It wasn't working properly, so I changed the code to:

if ($user->uid == 1) {
$OUTPUT .= ("<div class='menu'>" .menu_tree() ."</div>");
}

Is this appropriate? (Haven't been using Drupal long -- don't know all
the security or coding issues yet.)

I added to an existing menu block which now looks like:

global $user;
if ($user->uid) {
$OUTPUT="Welcome back, $user->name,<BR>
<UL>
<LI><a href=\"?q=queue\"><B>RATE STORIES</a></LI>
<LI><a href=\"?q=node/add/story\">ADD A NEWS STORY</a></LI>
<LI><a href=\"?q=node/add/event\">ADD AN EVENT</B></a></LI>
<LI><a href=\"?q=node/add/image\">ADD PICTURES</B></a></LI>
<LI><a href=\"?q=user/edit\">My Settings</a></LI>
<LI><a href=\"?q=logout\">Logout</a></LI>
</UL>";
}
else {
$OUTPUT="Welcome, visitor.";
}

if ($user->uid == 1) {
$OUTPUT .= ("<BR><div class='menu'>" .menu_tree() ."</div>");
}

return ($OUTPUT);

Will this cause any problems in the future?


Cheers,

Mark

--
[ Drupal support list | http://list.drupal.org/ ]



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise