How to edit the menu bar so as to remove profile and name in front of welcome in the dropdown?

474 views
Skip to first unread message

RAGHIB R

unread,
Dec 26, 2015, 2:38:34 PM12/26/15
to web2py-users
for example here, I want to remove profile in this pic and name in front of welcome. how to do this?

1.PNG

Massimo Di Pierro

unread,
Dec 27, 2015, 2:00:38 AM12/27/15
to web2py-users
Edit views/layout.html and remove {{=auth.navbar(....)}} which is responsible for drawing that part of the page. Then write your own code for it

{{if auth.user:}}
<a href="{{=URL('default','user/logout')}}">logout</a>
{{else:}}
<a href="{{=URL('default','user/login')}}">login</a>
<a href="{{=URL('default','user/register')}}">register</a>
{{pass}}

add html as needed depending on how you want it to look.

rajjm...@gmail.com

unread,
May 20, 2016, 9:01:40 PM5/20/16
to web2py-users
I just want to change the name from Profile to  Register. I have to do all these or there is another work around?

pbreit

unread,
May 22, 2016, 2:49:01 AM5/22/16
to web2py-users
That's the type of thing that it seems like it should be in the app, not the framework?

rajjm...@gmail.com

unread,
Jun 1, 2016, 2:13:45 AM6/1/16
to web2py-users
Yes. you are right. Just curious to know where Profile is defined like in which html file? I can't seem to find that.

Anthony

unread,
Jun 1, 2016, 7:55:19 AM6/1/16
to web2py-users
On Wednesday, June 1, 2016 at 2:13:45 AM UTC-4, rajjm...@gmail.com wrote:
Yes. you are right. Just curious to know where Profile is defined like in which html file? I can't seem to find that.

Do you want to know where the auth dropdown menu is defined, or where the actual Profile page is defined? Assuming you are talking about the scaffolding application, the menu is created by auth.navbar() and is included in layout.html. All of the Auth actions are handled via the user() function in the default.py controller (and the associated /views/default/user.html view).

Note, it doesn't make sense to change "Profile" to "Register" in the navbar. The way it works now is if the user is not logged in, the navbar includes a link to "Register", and if the user is logged in, the navbar instead includes a link to the "Profile" action (doesn't make sense for a logged in user to register). If you do not want to expose the "profile" action at all, you can instead add it to auth.settings.actions_disabled.

Anthony

rajjm...@gmail.com

unread,
Jun 1, 2016, 11:45:13 AM6/1/16
to web2py-users
Thank you Anthony. See attached. Just want to change the wording of it but keep everything same and working the way they are.
profile_wording.png

Anthony

unread,
Jun 1, 2016, 12:12:31 PM6/1/16
to web2py-users
You'd have to use server-side DOM manipulation:

import re
navbar
= auth.navbar()
navbar
.element(_href=re.compile('register'))[0] = 'Registration Page"

Or just take Massimo's advice and make a custom navbar.

Anthony

Ron Chatterjee

unread,
Jun 6, 2016, 2:45:00 PM6/6/16
to web2py-users
I get this error.

EOL while scanning string literal: <string>, line 1, pos 68

While typing 
navbar.element(_href=re.compile('register'))[0] = 'Registration Page"


So, I am guessing, it looks for the work (pattern) 'register' and change that to the 'registration page'. I printed out the navbar but I don't see the 'profile' anywhere. 

Anthony

unread,
Jun 6, 2016, 9:59:12 PM6/6/16
to web2py-users
On Monday, June 6, 2016 at 2:45:00 PM UTC-4, Ron Chatterjee wrote:
I get this error.

EOL while scanning string literal: <string>, line 1, pos 68

While typing 
navbar.element(_href=re.compile('register'))[0] = 'Registration Page"

Not sure how/why you are getting that error (hard to say without seeing all the code and the traceback). Of course, though, it will only work if the "register" item is in the navbar (which will only be the case if the user is not logged in).
 
So, I am guessing, it looks for the work (pattern) 'register' and change that to the 'registration page'.

Not exactly. It looks for the element whose _href attribute includes "register" in the URL (which is an anchor tag), and then it changes the first component of that element (which is the text displayed within the anchor tag).

Anthony

Ron Chatterjee

unread,
Jun 7, 2016, 11:37:47 AM6/7/16
to web2py-users
If the user is logged in, how would I change the "profile" word to "registration page" or "registration info". Which is (to me) more in line with how I see the info. 

Anthony

unread,
Jun 7, 2016, 12:42:04 PM6/7/16
to web2py-users
On Tuesday, June 7, 2016 at 11:37:47 AM UTC-4, Ron Chatterjee wrote:
If the user is logged in, how would I change the "profile" word to "registration page" or "registration info".

I understand if you don't want to use the label "Profile", but "Registration" is probably going to be a confusing alternative (most users will think of registration as a one-time sign-up event). Maybe something like "Update account".

Anyway, the idea is the same -- find the element with "profile" in the URL and change the text in its first component.

Anthony
Reply all
Reply to author
Forward
0 new messages