- Moderated by:
- Support
-
- rank:
-
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
Thanks in advance -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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; -
- rank:
-
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 -
- rank:
-
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 -
- rank:
-
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
--
Chestnut !
Support via Private message won't be answered...
http://dev.pnconcept.com
http://www.postnuke-france.org -
- rank:
-
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> -
- rank:
-
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 -
- rank:
-
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
