Quantcast
Channel: Open Data - name
Viewing all articles
Browse latest Browse all 2

Undo Drupal's over-aggressive shortening of user names

$
0
0

And use a real ellipses!

Drupal's theme_username() is used many places within Drupal, and shortens any name over 20 characters, which can be a lot if you encourage people to use full names. This can be undone with a preprocess function in your module or theme, just replace EXAMPLE with your module or theme name.

<?php
/**
* Undo template_preprocess_username()'s aggressive shortening of names.
*/
function EXAMPLE_preprocess_username(&$variables) {
 
$name = check_plain($variables['name_raw']);
  if (
drupal_strlen($name) > 35) {
   
$name = drupal_substr($name, 0, 35) . '&hellip;';
  }
 
$variables['name'] = $name;
}
?>

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images