>
> I've worked out how to remove the 'forget username?' and 'Retrieve 
> Password' entries from the navbar by editing gluon/tools.py, and restarting 
> server.
>
> This seems a bit severe, altering web2py source code. I imagine my changes 
> will be overwritten at next update.
>
> Is there a way to do it in the layout.html view?
>

First, do you want to disable those two actions altogether, or simply 
remove the links from the navbar (but still allow users to use those 
functions)? If the former:

auth.settings.actions_disabled = ['retrieve_username', 
'request_reset_password']

That will disable those actions (i.e., they won't be allowed via a call to 
auth(), though you could still call the individual functions themselves), 
and they will not appear in the navbar. See 
http://web2py.com/books/default/chapter/29/9#Settings-and-messages.

If you just want to edit the navbar, note that it is simply an HTML helper 
object (a SPAN object containing opening and closing brackets, some links, 
and separators), so you can manipulate it via the server-side DOM: 
http://web2py.com/books/default/chapter/29/5#Server-side-DOM-and-parsing.

In the navbar, those two items and their two separators start at the 5th 
item within the SPAN and include all but the last item (which is the 
closing bracket), so you could do:

navbar = auth.navbar()
del navbar[4:-1]

Anthony

Reply via email to