collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 197
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Shorten Username in Top Posters  (Read 9449 times)

0 Members and 1 Guest are viewing this topic.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Shorten Username in Top Posters
« on: August 31, 2009, 07:39:46 AM »
Would anyone know how I could shorten the usernames for the Top Posters block??
I have a few members with long usernames (Shawskin_Productions for example )
Would like the block to shorten that to Shawskin...

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #1 on: August 31, 2009, 05:30:48 PM »
Moved to the Custom Coding Board.

Find this code (sources/SPortal2.php file, line ~981):
Code: [Select]
'name' => $row['real_name'],
Replace with this code:
Code: [Select]
'name' => substr($row['real_name'], 0, 15),
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #2 on: August 31, 2009, 08:06:42 PM »
Thanks Nathaniel.. but that didn't seem to change anything :(

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Shorten Username in Top Posters
« Reply #3 on: August 31, 2009, 08:28:43 PM »
This is not possible in the way you want it.

You can't shorten every name to what you want. You can restrict how many characters appear, but that might not be what you want for every user.

Example, if I cut 15 chars, and my username was ThisIsATestLolLolLol, it would return: ThisIsATestLolL

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #4 on: August 31, 2009, 08:39:46 PM »
So you can't make it so that:
Username under 15 characters appear normal
Username over 15 characters are cutoff and a ... put after it ?

Obviously I can't ask people to change their usernames to suit a block. The block should be able to compensate for such obstacles.

The phpbb portal that I am using on my live site at present has this ability.. but the coding is totally different to that of SMF so I have no idea what I am looking at :(

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Shorten Username in Top Posters
« Reply #5 on: August 31, 2009, 10:06:28 PM »
That is possible, and is probably recommended.

Did you perform the edits LHVWB provided?

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #6 on: September 01, 2009, 03:38:17 AM »
LHVWB??? umm.. can't see any posts by a user with this name lol

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #7 on: September 01, 2009, 04:49:26 AM »
LHVWB??? umm.. can't see any posts by a user with this name lol

That used to be my username. ;)

That edit will simple shorten the usernames, you can change the length by changing the '15' value. If you really want to add an ellipsis '...' then I can post an edit.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #8 on: September 01, 2009, 09:18:32 AM »
The ellipsis identify that it has been shortened.. but as mentioned above.. I didn't notice a change after making that edit.. and I double checked that I had the right edit done ;)

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #9 on: September 02, 2009, 12:00:59 AM »
Have pulled apart my existing site to see how the shortened names work and I guess it should work with SP as well.. but not sure where to place this function to get it to work??

Code: [Select]
function sp_checksize($txt,$len)
{
if(strlen($txt) > $len)
{
$txt = truncate_string($txt, $len);
$txt .= '...';
}
return($txt);
}


And in sources/SPortal2.php file, line ~981

I have changed
Code: [Select]
'name' => $row['real_name'],
To
Code: [Select]
'name' => sp_checksize($row['real_name'],15),
I get the following error:
Quote
Fatal error: Call to undefined function sp_checksize() in /var/www/vhosts/ozsuperbikes.com/httpdocs/Sources/SPortal2.php on line 981

I guess thats because I don't know where to put that first function lol.. Anyone able to help me out with this please? :)

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #10 on: September 02, 2009, 12:39:47 AM »
Put it at the end of your SPortal2.php file.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #11 on: September 02, 2009, 12:52:03 AM »
hmmm.. now I get
Quote
Fatal error: Call to undefined function truncate_string() in /var/www/vhosts/ozsuperbikes.com/httpdocs/Sources/SPortal2.php on line 3229
lol

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #12 on: September 02, 2009, 12:58:59 AM »
Use the substr() function, like:
Code: [Select]
substr($txt, 0, $len)
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #13 on: September 02, 2009, 01:13:55 AM »
Sorry Nathaniel.. not sure where I need to add that?

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #14 on: September 02, 2009, 01:47:00 AM »
Replace this code:
Code: [Select]
truncate_string($txt, $len)
With that last code snippet I posted.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #15 on: September 02, 2009, 01:52:23 AM »
Thanks mate. That got rid of the errors.. but for some reason it's still not adjusting the length of the names :(

By the way.. where bouts in Aus are you?

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #16 on: September 02, 2009, 02:15:11 AM »
I'm in Melbourne.

Do you have any usernames over 15 characters? Try shortening the length from '15' to '8' or something smaller, 15 is probably a bit long.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #17 on: September 02, 2009, 02:23:00 AM »
Cool.. Gold Coast here ;)
Yeah already tried shortening the number.. but still nothing changed :(

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #18 on: September 02, 2009, 02:54:50 AM »
That would be due to the way that SP colors the usernames.

Some more edits:
Code: ("Find this code (/sources/Subs-SPortal2.php)") [Select]
$color_profile[$row['id_member']]['link'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '"' . (!empty($onlineColor) ? ' style="color: ' . $onlineColor . ';"' : '') . '>' . $row['real_name'] . '</a>';
Code: ("Replace with this code") [Select]
$color_profile[$row['id_member']]['link'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '"' . (!empty($onlineColor) ? ' style="color: ' . $onlineColor . ';"' : '') . '>' . $row['real_name'] . '</a>';
$color_profile[$row['id_member']]['short_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '"' . (!empty($onlineColor) ? ' style="color: ' . $onlineColor . ';"' : '') . '>' . sp_checksize($row['real_name'], 8) . '</a>';

Code: ("Find this code (SPortal2.php, line ~1021)") [Select]
$member['link']
Code: ("Replace with this code") [Select]
$member['short_link']
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #19 on: September 02, 2009, 03:16:12 AM »
Still nothing :( Thanks for the efforts though ;)

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #20 on: September 02, 2009, 03:18:13 AM »
Actually.. I'll retract that statement.. I edited the first instance instead of the one you noted.
Have corrected.. but now I have NO usernames being displayed lol

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Shorten Username in Top Posters
« Reply #21 on: September 02, 2009, 04:31:15 AM »
Ah, forgot about the block's link. ;)

Replace this code (SPortal2.php, line ~982):
Code: [Select]
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
With this code:
Code: [Select]
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'short_link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . sp_checksize($row['real_name'], 8) . '</a>',
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #22 on: September 02, 2009, 04:54:48 AM »
Almost ;)
It's shortening the names.. but from both ends lol.

Take a look at the Top Posters block on the right side at www.ozsuperbikes.com

The first poster is me.. and that appears coorect.
The second name is idroppedit but appears as it...
The last name in the list is Shawskin_Productions and for some reason it appears as _Productions...

Hmm.. actually.. after reading that it is cutting the front of the username rather than the back lol.

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #23 on: September 02, 2009, 04:58:13 AM »
Fixed.. a typo in my copy paste :D :D

Thanks heaps Nathaniel.. top work :)

Offline roomeat

  • Jr. Member
  • **
  • Posts: 51
    • Ozsportsbikes
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Shorten Username in Top Posters
« Reply #24 on: September 02, 2009, 04:58:43 AM »
Don't spose you want to have a crack at my scrolling recent topics?? lol ;)