Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 02:21 pm EST

Geeklog Forums

Dynamic Link Creation


Status: offline

sammykrupa

Forum User
Junior
Registered: 12/05/04
Posts: 28
Very Happy Very Happy
Hey!

I am trying to setup Dynamic Link Creation. Here is an example:

Text Formatted Code

http://gdfae.com/click-2134123412-2134123-<username of logged in person>


 


As you can see I need to have the [username of logged in person] changed to the username of logged in person. Is there anyway I can do this using blocks, static pages, whatever?

Thanks!
Sam Krupa
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The current user's username is available in the global variable $_USER['username'] (it's empty for anonymous users).

bye, Dirk
 Quote

sammykrupa

Anonymous
How can I use that on a page so it changes to the username of the logged in user? Can someone help me
 Quote

Status: offline

sammykrupa

Forum User
Junior
Registered: 12/05/04
Posts: 28
Anyone?
Sam Krupa
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
I already gave you the answer above ...
 Quote

sammykrupa

Anonymous
Yea, but whenever I put $_USER['username'] on a page nothing happens? What am I doing wrong? If I am doing something stupid I don't know it.
 Quote

sammykrupa

Anonymous
I am confused! Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me Can someone help me
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
Text Formatted Code
<?php
$retval = 'http://gdfae.com/click-2134123412-2134123-';
$retval .= $_USER['username'];
return $retval;
?>
 

that will only work in your header.thtml, a phpblock, or a PHP enabled staticpage.
 Quote

sammykrupa

Anonymous
Thank you!
 Quote

sammykrupa

Anonymous
One question: I put that into my lib-common.php file then I call it when I make the block. It shows the link but it does not show the username part, what am I doing wrong?

Also: how do I make it so that it is an active link like this?

Thanks!
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
you need to be a bit more specific... what exactly are you putting into your lib-common (and why not in your lib-custom?)? how are you calling it?

try this
Text Formatted Code
function user_link(){
    global $_USER;
    $retval = '<a href="http://gdfae.com/click-2134123412-2134123-';
    $retval .= $_USER['username'] . '">';
    $retval .= $_USER['username'] . '</a>';
    return $retval;
}
 
now just call user_link() where you need this link to be inside your phpblock. or, easier, just put this code inside your phpblock.
 Quote

sammykrupa

Anonymous
Victory!

I owe you one! Thanks!
 Quote

All times are EST. The time is now 02:21 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content