Download & Extend

Main Navigation Box should allow for greater flexibility in customization (user.module)

Project:Drupal core
Version:7.x-dev
Component:user system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

http://drupal.org/node/24593 demonstrates a method of changing default words and phrases without hacking into core modules, but the main navigation block only supports this half way.

For anonymous users, a call to t('Navigation') is made. For logged-in users, the title is automatically set to the username. The website author has no option but to hack core files or do theming tricks in order to change this.

I propose an additional t() call so that this, too, is easily modifiable by the end user.

I haven't had much luck making patches, so I will write here the one line code change.

Line 534 of user.module (CVS) change:
           $block['subject'] = $user->uid ? $user->name : t('Navigation');
to:
           $block['subject'] = $user->uid ? t('%navigation_username', array('%navigation_username', $user->name)) : t('Navigation');

Comments

#1

Version:4.7.2» x.y.z

bah, the change should be to this:
          $block['subject'] = $user->uid ? t('%navigation_username', array('%navigation_username' => $user->name)) : t('Navigation');

#2

Version:x.y.z» 7.x-dev

Feature request, moving to cvs.

#3

Pardon my opinion, but I think your proposal is not totally "right" either. IMHO, the more consistent way to do this is with theme_username as my patch provides.

AttachmentSizeStatusTest resultOperations
user_theme.patch483 bytesIdleFailed: Failed to apply patch.View details | Re-test

#4

Status:active» needs review

#5

NancyDru - Your might want to unset the uid before passing $account so that you don't get a hyperlink in the block title.

#6

Wow.... this is an old thread, from when I first began using Drupal! I'm glad something has come of it.

The original issue was that I wanted for the block title to be configurable, which was not possible in D4.7. That's why I suggested a call to t().

In D6 (and D7), it is now possible to override a block's title in the block configuration page. The problem is that, if you use the block configuration screen to change the block title, then the same title will be used for both logged in and logged out users alike.

To sum it up:

  1. As it is now in D7:
    • Anonymous users have the title "Navigation" by default, customizable via the t() function.
    • Authenticated users have the title of their username by default.
    • Using the block administration page, the title can be changed to something else, but the different titles for anonymous/authenticated users is lost.
    • NancyDru's patch will not change this behavior. It will use theme_username() to standardize the presentation of the username.
  2. The way that my original post suggested:
    • Anonymous users have the title "Navigation" by default.
    • Authenticated users have the title of their username passed as a variable through the t() function.
    • The block title for both Anonymous and Authenticated users can be customized via the t() function.

Do you see the difference? The original, core code allows for a customized (translated) text for anonymous users, but only the username for authenticated users. The original intent of my suggestion was to allow for a custom title for anonymous users as well as a custom (but different) title for Authenticated users.

Using the theme_username function will not achieve this goal. It may actually complicate matters, as Moshe mentions regarding the possible hyperlink in the block title.

Also, if you unset the uid, won't it print "(not verified)" after the username?

BTW, I'm not intending to be nit-picky. I've been around long enough to know how much you all have done for the Drupal project. If the outcome is not the same as my original suggestion, then that's OK. I know that I've contributed in other ways. ;)

#7

@Moshe: Thanks for the tip. Even if the uid is gone, if a homepage is present, there will be a hyperlink. But this is only on the navigation menu for the currently signed in user; how likely is he/she to click on their name?

I would have to do some more checking to see if I need to clone the user object before unsetting the uid.

#8

@Moshe: If you unset the uid then you get "not verified" which I don't think anyone wants. Leaving it as above, then clicking on the user name in the Navigation block is pretty much the same as "My account." I don't see that as a problem.

#9

Status:needs review» needs work

The last submitted patch failed testing.

#10

Well, those "detailed results" don't tell me why it failed. It works fine on my system.

#11

Status:needs work» needs review

Here's a patch against this morning's -dev.

AttachmentSizeStatusTest resultOperations
user_theme.patch483 bytesIdleFailed: Failed to apply patch.View details | Re-test

#12

Status:needs review» needs work

The last submitted patch failed testing.

#13

That's pure BS.

#14

In my freshly installed 7.9 the title is always 'Navigation' and never the user name.
I can change the block name (e.g. to or any other text) and it will display that overrule name. But it will never show the user name. Is that a bug? Or am I missing something in the settings of Drupal? My Drupal 6 (production) site is displaying the user name correctly.

nobody click here