Log in

View Full Version : Calling functions / declaring with eval


act
04-21-2002, 11:39 AM
I am looking for a solution for hours now but none of the forum postings were able to help me, neither here nor on vbulletin.com..

All i want to do is simply declare a new variable called $medals which can be used in the Postbit template.
The content of this $medals will be something like

$medals = getMedals($uid,another_param);

So, i am aware that you cannot execute php-code in templates. What i am looking for is the procedure how to make this $medal a valid variable in the Postbit-Template.

I have read about adding another templates and eval'ing some code but i am a bit confused actually. I am not sure why i should add a new template which can not hold any php-code anyways to eval something with its content.

I tried a few things like adding stuff to phpinclude or global.php but its not doing the magic, so if i have to modify anything, please let me know the appropriate position within the php-file.

Thanks for you help!

-act

PS: just noticed that its basically similiar to that ONLINE/OFFLINE-Images you are showing here in the postings beneath the Username. So if you can explain me how to implement those, it will probably help me with my problem as well.

Admin
04-21-2002, 12:07 PM
Just stick that line of code (with getMedals() and all) in functions.php, inside the getpostbit() function. For $uid use $post['userid'].

act
04-21-2002, 12:14 PM
Thanks FireFly for saving my day .. works perfect! ;)

-act

act
04-22-2002, 07:17 AM
additional question, but same matter.

I would also like to use those variable stated above in the profile display screen. I found the the function getuserinfo () with the getinfo-section in the functions.php, but when adding


global $userawards;
$userawards=getUserAwards($userid],true);


it will tell me that getUserAwards is an undefined function, though its working in the upper part of function.php within the postbit function. The getUserAwards()-fnc is included in the phpinclude template.

Greets
-act

Admin
04-22-2002, 11:52 AM
I believe getuserinfo() is first called in sessions.php before the phpinclude template is eval()'ed, so the function is not yet defined in that stage. Move the function definition to functions.php or just user it in member.php (I suggest the latter, since you don't want to getUserAwards() every time a user info is called for).