Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Goto page: 1 - 2 [+1]

Bottom
Echoing a username
  • Posted: 08.04.2005, 07:21
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    Hello everyone,

    I am wondering how to echo a username. I am editing the "My account" but I want to know how to add a ref link. I have everything done already with pnAffliate but I didn't want all the mumbo jumbo that came with it, all I wanted was the ref link to display in the "My Account" portion, but I can't make it display.

    This is the only thing I have added at the end of the NS-User tool.php file. I know im missing something but I dont know what

    Code

    function pnAffiliate_user_viewtextlinks()
    {
     
    global $SERVER_NAME,$HTTP_HOST;
    $sitename = $HTTP_HOST;
    if (!isset($sitename) || empty($sitename)) $sitename=$SERVER_NAME;
    $username=pnUserGetVar('uname');

    $output->Text(_pnAffiliateAFLINK." <b>http://$sitename/?ref=$username</b>");
    }


    Thanks in advance
  • Posted: 08.04.2005, 09:38
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    Try using verbatim mode?

    Code

    function pnAffiliate_user_viewtextlinks()
    {
     
    global $SERVER_NAME,$HTTP_HOST;
    $sitename = $HTTP_HOST;
    if (!isset($sitename) || empty($sitename)) $sitename=$SERVER_NAME;
    $username=pnUserGetVar('uname');

    $output->SetInputMode(_PNH_VERBATIMINPUT);
    $output->Text(_pnAffiliateAFLINK." <b>http://$sitename/?ref=$username</b>");
    $output->SetInputMode(_PNH_PARSEINPUT);
    }


    --
    Photography | PHP | Other
  • Posted: 08.04.2005, 18:33
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    nope that didnt work. I'm wondering if the function part is wrong because. where it says "function pnAffiliate_user_viewtextlinks()" I don't think thats reading it well. Is there anyway it can just echo the username such as "Welcome $username"? That's all I'm really asking Ill put the name of my website before and then it just has to add itself after the "index.php=ref?". I've seen it happen in templates and stuff but never knew how it was done
  • Posted: 08.04.2005, 18:48
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    28.11.08
    Posts:
    13417
    Presumably you are actually calling the function at the right place?

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 08.04.2005, 19:14
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    Simon's right...if you don't call the function in the right spot, you get a big ol' nothing. ...but if you're just looking to echo the username, you don't really need a function...after all, pnUserGetVar IS a function...so...

    ...if you're trying to do it in your theme, you can call the function by echo'ing it:
    echo pnUserGetVar('uname');

    ...whereas, if you're doing it in a module, you can call the function like this ("output" instead of echo)...
    $output->Text(pnUserGetVar('uname'));

    Does that clear it up?

    --
    Photography | PHP | Other
  • Posted: 08.04.2005, 19:16
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    tools.php isn't parsed by the pnHTML class...

    Code

    echo pnAffiliateAFLINK." <b>http://".pnVarPrepForDisplay($sitename)."/?ref=".pnVarPrepForDisplay(pnUserGetVar('uname'))."</b>";


    Or else, you must call the class :

    Code

    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);

    $output->Text(_pnAffiliateAFLINK." <b>http://$sitename/?ref=$username</b>");
    $output->SetInputMode(_PNH_PARSEINPUT);

    return $output;


    something like that...

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 08.04.2005, 19:18
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    Chestnut...thanks for putting me back on track...I forgot what the original question actually was.... DOH!

    --
    Photography | PHP | Other
  • Posted: 08.04.2005, 20:01
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    Sorry for this once again very noob question (im very new to PHP) but what exactly do I need to put on the end of my account page? Is this all I need or do I need more?

    Code

    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);

    $output->Text(_pnAffiliateAFLINK." <b>http://$sitename/?ref=$username</b>");
    $output->SetInputMode(_PNH_PARSEINPUT);

    return $output;
  • Posted: 08.04.2005, 20:04
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    I don't think I've ever ended with: return $output

    How about: return $output->GetOutput();

    ...I'm still pretty green myself...

    ;)

    --
    Photography | PHP | Other
  • Posted: 08.04.2005, 20:53
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    Nice catch... forgot that last little thing...

    Hard to do it by memory... :)

    Gazuz... I'm not sure you're doing the right thing... dunno why you want to add anything in the tools.php...

    Where exactly do you want that link to be shown ?

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 09.04.2005, 07:42
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    id like each member to have their ref link ready in the "my account" section. I will make a ref contest so i want the links to be at an easy access point
  • Posted: 10.04.2005, 06:48
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    On the profile page I suppose ...
    user.php?op=userinfo&uname=XXX

    Then do a simple echo in the (NS-)User/user.php in the user_userinfo function...

    The username is probably already stored in a var in the function (I don't have in front of the eyes)...

    Code

    echo "<b>http://$sitename/?ref=".pnVarPrepForDisplay($username)."</b>";


    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 10.04.2005, 23:59
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    Is there anything else thats just plain and easy 1 or 2 lines of code? all it will do is make a link to http://www.mysite.com/index.php?ref=<username> and change that <username> to the actual username without making anything new or adding more lines of code. It should already exist somewhere else and the only thing needed is to call it out. BTW im using AutoTheme Lite 0.9</username></username>
  • Posted: 11.04.2005, 01:32
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221

    gazuz

    Is there anything else thats just plain and easy 1 or 2 lines of code?


    Not complicated enough ?

    You were about to add a 10 or so lines of code in tools.php while I give you a "one line" instead... So as far as "adding code" is concerned, I think you can manage it.

    That line of code wich I give again with a correction :
    (in user_userinfo() in (NS-)User/user.php)

    Code

    echo "<a href=\"http://www.YOURSITE.com/index.php?ref=".pnVarPrepPrepForDisplay($uname)."\" title=\"Ref\">Referal link</a>";


    Otherwise, no, there is nothing that will do exactly this for you. If you want to use it everywhere, than do yourself a plugin in AT if it can be done...

    But making it in the tools.php won't be of much help.

    Remember that I answer you on what you ask at first : Adding to the "My Account" the ref link for the user currently viewed.
    :wink:

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 14.04.2005, 06:37
     
    gazuz
    rank:
    Freshman Freshman
    registered:
     April 2005
    Status:
    offline
    last visit:
    14.04.05
    Posts:
    10
    alright so the tools.php thing didnt work out too much ajnd I dropped the idea of it anyways since I found another way to do. I'd like to add it in the "Edit User Info" as a text or an already filled in box. I am not sure what file to edit either since I know there is a field to fill in in the admin area. The code can be a million lines long. But as long as I understand how to input it I'm ok with it

Goto page: 1 - 2 [+1]

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula