[drupal-devel] [feature] Adjustable username crop

tangent drupal-devel at drupal.org
Mon Jan 31 11:34:05 UTC 2005


 Project:      Drupal
 Version:      4.5.2
 Component:    node system
 Category:     feature requests
 Priority:     normal
 Assigned to:  com2
 Reported by:  com2
 Updated by:   tangent
 Status:       patch

In some cases there may not be a need to truncate the output at all. We
should consider using CSS to adjust the display of text rather than
truncating strings to arbitrary lengths that may be less than can be
viewed in a given resolution.
Given the following markup
<div class="container">
  This is a string which may be displayed in a
  small area and may be truncated if the container
  is too small to contain it.
</div>
the following CSS may be used to control the overflow of the container.
.container {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
Use of the proprietary (MS Internet Explorer) "text-overflow" property
may be used to show ellipsis on a container with hidden content.
Javascript could be used to display ellipsis on these containers for
other browsers as well, though it may well not be worth doing so.
Using CSS to control display in this manner gives greater control for
supporting variable environments (graphical browser, wap browser, text
browser) without limiting the content that I user needs to see.


tangent



Previous comments:
------------------------------------------------------------------------

January 27, 2005 - 11:11 : com2

Attachment: http://drupal.org/files/issues/common_0.diff (546 bytes)

Some people might not like it when long usernames are cropped in the
node haeder. This patch can be applied to includes/common.inc version
4.5.2 and creates a new variable 'user_name_crop' to adjust the crop
length.


------------------------------------------------------------------------

January 27, 2005 - 15:32 : com2

Attachment: http://drupal.org/files/issues/common_1.diff (544 bytes)

I had the numbers wrong. In the original code it was cropped at 15, not
at 10 like in my diff. I also changed it a bit to avoid negative
argaments. Attached the new diff from version 4.5.2. 
if ($object->uid && $object->name) {
     // Shorten the name when it is too long or it will break many
tables.
    if (strlen($object->name) > variable_get('user_name_crop', 15)+5) {
      $name = truncate_utf8($object->name,
variable_get('user_name_crop', 15)) .'...';
     }
     else {
       $name = $object->name;


------------------------------------------------------------------------

January 27, 2005 - 16:00 : Bèr Kessels

IMO this should be done in a theme, not with yet another config option.
what about theme_username() ?


------------------------------------------------------------------------

January 27, 2005 - 16:07 : killes at www.drop.org

theme_username++
format_name is one of the functions I always need to modify. theme_date
would be nice, too.


------------------------------------------------------------------------

January 27, 2005 - 16:27 : Dries

This should be done in the theme.


-- 
View: http://drupal.org/node/16299
Edit: http://drupal.org/project/comments/add/16299





More information about the drupal-devel mailing list