[development] Menu system question

Larry Garfield larry at garfieldtech.com
Sat Dec 24 10:20:23 UTC 2005


There's a couple of ways, depending on your drupal version.

Under 4.6, you can stick some PHP code into your theme file to display one 
link if $user->uid is set and non-zero and the logout link otherwise.  It's 
not the cleanest solution, but it's very easy to do (~5 lines if you're 
verbose about it) and I did it myself on one site recently.

Under 4.7, you can put blocks into the header of the page.  The same technique 
would work, but instead of putting it into the theme file make a custom block 
that uses PHP code, and put the same code in there.  Then position that block 
into the header.  

There was talk of putting PHP code into menu entries in 4.7, but I don't 
recall if that got in or not.  Really, though, I suspect it's overkill for 
this.

In any case, simply disable the login block completely.

Cheers.

On Saturday 24 December 2005 03:57 am, Piotr Krukowiecki wrote:
> Hi,
>
> I wanted to have a 'log in' link that behaves like 'log out'. I.e. it is
> visible by anonymous but not by logged in person. I'd use 'log in' and
> 'log out' in secondary links in header - I don't want to have this huge
> login box in my sidebar...
> After clicking the 'log in' link the user should be directed to normal
> 'user/login' page, with "register", "forgot password" tabs...
>
> I think everything would work if I could combine MENU_DEFAULT_LOCAL_TASK
> with MENU_SUGGESTED_ITEM. We could add this flag to user.menu's
> user/login link. But now it does not work - produces "front page" link
> (I think it has something to do with default local task being redirected
> to it's parent).
>
> Is there any other way to have such 'log in' link? If not, could we
> change core somehow to make this possibile? Or is there any other way to
> have such link?

-- 
Larry Garfield			AIM: LOLG42
larry at garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson


More information about the development mailing list