Displaying Username

Discussion forum for MOD Writers regarding MOD Development.
Locked
micsta
Registered User
Posts: 126
Joined: Tue Apr 22, 2008 11:11 am

Displaying Username

Post by micsta » Wed Aug 04, 2010 12:48 pm

I have the following code in my overall_header;

Code: Select all

<!-- IF S_USER_LOGGED_IN -->Logged in as <a href="{U_PROFILE}">{S_USERNAME}</a><!-- ENDIF --><br />
which does as it should, but I want the link to display as bold with the usergroup color as well (as you would see in whoisonline/last post author etc.). What should I be replacing the {S_USERNAME} with, I've had a look through some of the language files for related stuff but haven't got it figured yet.

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Displaying Username

Post by AmigoJack » Wed Aug 04, 2010 1:18 pm

Open /includes/functions.php and find the following line (around line 4225):

Code: Select all

		'S_USERNAME'			=> $user->data['username'],
After that line, add the following one:

Code: Select all

		'S_USERNAME_COLOUR'=> get_username_string( 'no_profile', $user-> data['user_id'], $user-> data['username'], $user-> data['user_colour'] ),
Open /styles/xxx/template/overall_header.html and use it like this:

Code: Select all

<a href="{U_PROFILE}">{S_USERNAME_COLOUR}</a>
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

micsta
Registered User
Posts: 126
Joined: Tue Apr 22, 2008 11:11 am

Re: Displaying Username

Post by micsta » Wed Aug 04, 2010 1:46 pm

Thanks, I'll see how it goes...

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Displaying Username

Post by RMcGirr83 » Wed Aug 04, 2010 1:57 pm

AmigoJack wrote:Open /includes/functions.php and find the following line (around line 4225):

Code: Select all

		'S_USERNAME'			=> $user->data['username'],
After that line, add the following one:

Code: Select all

		'S_USERNAME_COLOUR'=> get_username_string( 'no_profile', $user-> data['user_id'], $user-> data['username'], $user-> data['user_colour'] ),
Open /styles/xxx/template/overall_header.html and use it like this:

Code: Select all

<a href="{U_PROFILE}">{S_USERNAME_COLOUR}</a>
can just be

Code: Select all

'S_USERNAME_COLOUR'=> get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
with the html being

Code: Select all

<!-- IF S_USER_LOGGED_IN -->Logged in as {S_USERNAME_COLOUR}<!-- ENDIF --><br />
as the mode full will build the link automagically.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

micsta
Registered User
Posts: 126
Joined: Tue Apr 22, 2008 11:11 am

Re: Displaying Username

Post by micsta » Wed Aug 04, 2010 2:00 pm

Hmmm, didn't work, came up blank...

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Displaying Username

Post by RMcGirr83 » Wed Aug 04, 2010 2:16 pm

Are you responding to my post or the one from AmigoJack? If from AmigoJack, that's because he has spaces within the code which is what is producing the error (a blank white page is usually an indication of a suppressed php error), namely these

Code: Select all

$user-> data['user_id']
see the space after the -> :?:
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

micsta
Registered User
Posts: 126
Joined: Tue Apr 22, 2008 11:11 am

Re: Displaying Username

Post by micsta » Wed Aug 04, 2010 10:14 pm

Thanks for the help guys, it now works with the latter code - again, thanks for your help... ;)

User avatar
AmigoJack
Registered User
Posts: 5659
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Displaying Username

Post by AmigoJack » Sat Aug 07, 2010 8:40 pm

RMcGirr83 wrote:If from AmigoJack, that's because he has spaces within the code which is what is producing the error (a blank white page is usually an indication of a suppressed php error), namely these

Code: Select all

$user-> data['user_id']
see the space after the -> :?:
Out of curiosity: which versions of PHP have issues with spaces around operators? I'm doing

Code: Select all

$oObject-> method();
$iOne= $iTwo+ $iThree;
$aArray= array( 1=> 'one' );
all night long with 5.2.x+ and never hit any errors, notices or else...
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Locked

Return to “[3.0.x] MOD Writers Discussion”