Hello,

Currently, my website cuts off authors names at around 15 characters
Example:
Firstname lastna...

How would I increase the display length of the author field to do:
Example:
Firstname lastname

Thanks

Update: Got it, thanks.

Comments

dnewkerk’s picture

I haven't tested this code (it's extracted from some longer code that does work)... but hopefully it gets you started. In my case it is in a module, but you should be able to put it in your template.php file, changing YOURTHEME to the correct name:

function YOURTHEME_preprocess_username(&$vars) {

  $account = $vars['account'];

  // Revise the name trimming done in template_preprocess_username.
  $name = $vars['name_raw'] = format_username($account);

  // Trim the altered name as core does, but with a higher character limit.
  if (drupal_strlen($name) > 25) {
    $name = drupal_substr($name, 0, 25) . '...';
  }

  // Assign the altered name to $vars['name'].
  $vars['name'] = check_plain($name);

} // End preprocess_username.
rawrzors’s picture

Hi David,

I tried your code with no success. Maybe it is because I'm terrible at php.

Is there any other way?

Thanks

albie001’s picture

This worked for me, thanks

peetrovich’s picture

Thanks. It works, D7.69.

rawrzors’s picture

I noticed these forums have an increased display length (i.e. Drupal Security Team). I know this is possible...would anyone care to enlighten me? :)

circassian’s picture

0 - Version Drupal 7;

1 - Open [includes\theme.inc];

2- Go to line 2743;

  if (drupal_strlen($name) > 20) {
    $name = drupal_substr($name, 0, 15) . '...';
  }

3 - Increase max length by changing 15 value ;

4 - Good Luck ^_^;

dnewkerk’s picture

That's hacking core, and should never be done for any reason. Drupal allows us to override things cleanly without hacking core.