TinyPortal

General => Chit chat => Topic started by: disisme on February 15, 2006, 05:10:52 PM

Title: embedding $context['user'] in a href
Post by: disisme on February 15, 2006, 05:10:52 PM
Guys, I can add the button just fine to the home page (running Bloc's Cerberus theme), but I want to embed the forum username in the href link that launches teamspeak.

Teamspeak is launched from a web page like this :
"teamspeak://xx.xx.xx.xx:8767/nickname=name_I_need_to_pass"

Now, in the index.template.php it uses $context['user'] to store the forum username.  I've tried the following 2 lines, but get template errors :
"teamspeak://xx.xx.xx.xx:8767/nickname=$context['user']?password=party"
and
"teamspeak://xx.xx.xx.xx:8767/nickname=" . $context['user'] . "?password=party"

the ? within the string is a continuation character specific to teamspeak and may be causing the problem.  I get 2 distincly different errors with those 2, which probably isnt surprising to you guys who are au fait with php and html.  The first one complains about the single quote in context.  The second one ends the string at the double quote after nickname=.  Not surprising, really.

How can I pass that variable within the string?

Heres the full line of code I am using against the button :

                          <a href="teamspeak://xx.xx.xx.xx:8767/**STUFF_I_NEED_HERE***">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/voxchat.GIF" alt="chat" style="margin: 2px 0;" border="0" />' : 'chat'), '</a>', $context['menu_separator'], '
Title: Re: embedding $context['user'] in a href
Post by: IchBin on February 15, 2006, 05:14:22 PM
Did you try this:

nickname=' . $context['user'] . ' <---single quotes instead of double.
Title: Re: embedding $context['user'] in a href
Post by: disisme on February 15, 2006, 05:19:13 PM
oh man...thats close.... it didnt error, but it threw me in as 'Array'.  Let me check if thats the right var name.  It may not be resolved at that point.
Title: Re: embedding $context['user'] in a href
Post by: IchBin on February 15, 2006, 05:28:09 PM
I do believe it is actually this:

$context['user']['name']
Title: Re: embedding $context['user'] in a href
Post by: disisme on February 15, 2006, 05:34:08 PM
Ithink you omay be right.... let me try that
Title: Re: embedding $context['user'] in a href
Post by: disisme on February 15, 2006, 05:39:07 PM
you are, indeed, correct.  Thanks you sir, your a champion!