Is there a way to "truncate" a name?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Is there a way to "truncate" a name?
Mindvacant
CZ Newbie
Mindvacant has been a member for over 20 year's 20 Year Member
Website:
Status: Offline
Joined: Dec 25, 2003
0.00 posts per day
Posts: 22
Points: 1,942
   
Hi,

Referring to your "Top-Posters" BLOCK

I'm wondering if there might be a way to "limit" the number of characters that appear for a user's name?

Several of mine registered with really long handles i.e. xxx_xxxxxxxxxxxx_xxxx.
That length obviously destroys the display, so I'm looking for a method of "forcing" the block to take say "the first 8 chars".

Thanks in advance.


Regards



Back to top Reply with quote
#2   
Telli
Site Admin
Telli has been a member for over 20 year's 20 Year Member
Occupation: Self Employed
Age: 45
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.06 posts per day
Posts: 8089
Points: 494,430
   
You need the name variable if you can get that then you would use a strlen this is something like what you want, this is based on the variable

$session[uname]

if(strlen($session[uname]) > 15) {
   $session[uname2] = substr($session[uname],0,15);
        $session[uname2] .= "..";


The .. is what would follow any name over 15 characters.

Telli



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
Mindvacant
CZ Newbie
Mindvacant has been a member for over 20 year's 20 Year Member
Website:
Status: Offline
Joined: Dec 25, 2003
0.00 posts per day
Posts: 22
Points: 1,942
   
Thanks very much.

Sorry, but I'm relatively new at this. Where "precisely" do I put the code into the file?



Back to top Reply with quote
#4   
Telli
Site Admin
Telli has been a member for over 20 year's 20 Year Member
Occupation: Self Employed
Age: 45
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.06 posts per day
Posts: 8089
Points: 494,430
   
It would go right after the sql query post the contents of the block and I can show you.

Telli




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   
Mindvacant
CZ Newbie
Mindvacant has been a member for over 20 year's 20 Year Member
Website:
Status: Offline
Joined: Dec 25, 2003
0.00 posts per day
Posts: 22
Points: 1,942
   
You can show me? If you can that'd be great, because I'm lost.

------------------
<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi (fbc@mandrakesoft.com) */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/************************************************************************/
/* block-Top_Posters.php */
/* =========================== */
/* */
/* Copyright (c) 2003 by chatserv (chatserv@nukeresources.com) */
/* http://nukeresources.com */
/************************************************************************/
/* Cosmetic changes by dvsDave at [ Register or login to view links on this board. ] */
/* http://controlbooth.com */
/************************************************************************/
/* Tapped By Telli for GTNextgen0.4 */
/* http://codezwiz.com/ */
/************************************************************************/
if (eregi("block-Top_Posters.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$a = 1;
global $user, $cookie, $sitename, $prefix, $user_prefix, $dbi, $admin, $module_name;
$result=sql_query("SELECT user_id, username, user_posts, user_avatar FROM ".$user_prefix."_users ORDER BY user_posts DESC LIMIT 0,5", $dbi);
while(list($user_id, $username, $user_posts, $user_avatar) = sql_fetch_row($result, $dbi)) {
$content .= "<div align=\"left\"><table class=\"outer\" cellpadding=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" cellspacing=\"1\" border=\"0\">";
$content .= "<tr class=\"even\" vAlign=\"middle\">";
$content .= "<td align=\"middle\">";
if ($user_avatar=="") {
$content .= " ;; ;;<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"modules/Forums/images/avatars/noimage.gif\" border =\"0\" width=\"32\"></a></td>";
}
else
if (eregi("http://", $user_avatar)) {
$content .= " ;; ;;<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"$user_avatar\" border =\"0\" width=\"32\"></a></td>";
}
else
$content .= " ;; ;;<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"modules/Forums/images/avatars/$user_avatar\" border =\"0\" width=\"32\"></a></td>";
$content .= "<td align=\"middle\"> ;;<a href=\"forum-userprofile-$user_id.html\">$username</a> ;;<br> ;;<a href=\"fsearch-author-$username.html\">Posts:</a> ;;<br>";
$content .= " ;;<a href=\"fsearch-author-$username.html\">$user_posts</a> ;;</td>";
$content .= "</tr>";
$content .= "</table></div><hr>";
}

?>



Back to top Reply with quote
#6   
Telli
Site Admin
Telli has been a member for over 20 year's 20 Year Member
Occupation: Self Employed
Age: 45
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.06 posts per day
Posts: 8089
Points: 494,430
   
<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi (fbc@mandrakesoft.com) */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/************************************************************************/
/* block-Top_Posters.php */
/* =========================== */
/* */
/* Copyright (c) 2003 by chatserv (chatserv@nukeresources.com) */
/* http://nukeresources.com */
/************************************************************************/
/* Cosmetic changes by dvsDave at [ Register or login to view links on this board. ] */
/* http://controlbooth.com */
/************************************************************************/
/* Tapped By Telli for GTNextgen0.4 */
/* http://codezwiz.com/ */
/************************************************************************/
if (eregi("block-Top_Posters.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$a = 1;
global $user, $cookie, $sitename, $prefix, $user_prefix, $dbi, $admin, $module_name;
$result=sql_query("SELECT user_id, username, user_posts, user_avatar FROM ".$user_prefix."_users ORDER BY user_posts DESC LIMIT 0,5", $dbi);
while(list($user_id, $username, $user_posts, $user_avatar) = sql_fetch_row($result, $dbi)) {
$content .= "<div align=\"left\"><table class=\"outer\" cellpadding=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" cellspacing=\"1\" border=\"0\">";
$content .= "<tr class=\"even\" vAlign=\"middle\">";
$content .= "<td align=\"middle\">";
if ($user_avatar=="") {
$content .= "<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"modules/Forums/images/avatars/noimage.gif\" border =\"0\" width=\"32\"></a></td>";
}
else
if (eregi("http://", $user_avatar)) {
$content .= "<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"$user_avatar\" border =\"0\" width=\"32\"></a></td>";
}
else
$content .= "<a href=\"forum-userprofile-$user_id.html\"><img alt src=\"modules/Forums/images/avatars/$user_avatar\" border =\"0\" width=\"32\"></a></td>";
if(strlen($username) > 15) {
$username = substr($username,0,15);
$username .= "..";
}
$content .= "<td align=\"middle\"><a href=\"forum-userprofile-$user_id.html\">$username</a><br><a href=\"fsearch-author-$username.html\">Posts:</a><br>";
$content .= "<a href=\"fsearch-author-$username.html\">$user_posts</a></td>";
$content .= "</tr>";
$content .= "</table></div><hr>";
}

?>


There ya go. And the this is what i added



if(strlen($username) > 15) {
$username = substr($username,0,15);
$username .= "..";
}
$content .= "<td align=\"middle\"><a href=\"forum-userprofile-$user_id.html\">$username</a><br><a href=\"fsearch-author-$username.html\">Posts:</a><br>";




Telli



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#7   
Mindvacant
CZ Newbie
Mindvacant has been a member for over 20 year's 20 Year Member
Website:
Status: Offline
Joined: Dec 25, 2003
0.00 posts per day
Posts: 22
Points: 1,942
   
Thanks again -

Just to make sure I understand -
The lines below are saying - if the UserName is = to or > 15, limit the displayed letters to 15. Is that correct?

So if I were to change the 1st "15" to 8, and the 2nd "15" to 3 - the system would display the 1st 3 letters of any UserName that contained 8 or more letters.

if(strlen($username) > 15) {
$username = substr($username,0,15);



Back to top Reply with quote
#8   
Telli
Site Admin
Telli has been a member for over 20 year's 20 Year Member
Occupation: Self Employed
Age: 45
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.06 posts per day
Posts: 8089
Points: 494,430
   
You got it!

Telli




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum