11
3lr0n
Re: data from custom user fields on forums
  • 2009/4/29 20:17

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


This

$profile = $profile_handler->get($xoopsUser->getVar('uid'));

give me a

Fatal error: Call to a member function on a non-object

when i set it in the template inside php tags

Spanish Overclocking Community xoops based site : http://www.overclocking.es

12
3lr0n
Re: data from custom user fields on forums
  • 2009/4/29 20:22

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


I tried it 2 ways,


<{php}>
if (is_object( $xoopsUser )) {
$GLOBALS['xoopsTpl']->assign('myField', $xoopsUser->getVar('user_from'));
}
<{/php}>

<{$myField}>

This doesnt work either, because I guess xoopsUser is not created as an object there, so it fails..

Any other option to do it?

Spanish Overclocking Community xoops based site : http://www.overclocking.es

13
trabis
Re: data from custom user fields on forums
  • 2009/4/30 13:02

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Use $GLOBALS['xoopsUser'] instead of $xoopsUser.

14
3lr0n
Re: data from custom user fields on forums
  • 2009/4/30 19:44

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


I tried this code inside newbb_tread.html (overriding default template in themes/modules/newbb folder)

<{php}>
  
$profile_handler xoops_getmodulehandler('profile''profile');
$profile $profile_handler->get($GLOBALS['xoopsUser']->getVar('uid'));
$from $profile->getVar('user_from');
<{/
php}>
 <{
$from}>


No error, but seems to have a $from vble without value (nothing is printed on the screen).

I have to say that in the template there is already a smarty variable that could be used for gather the post authot user id, is $topic_post.poster.uid.

Any other idea to make this work?

thks
Spanish Overclocking Community xoops based site : http://www.overclocking.es

15
3lr0n
Re: data from custom user fields on forums
  • 2009/5/3 19:07

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


bump!
Spanish Overclocking Community xoops based site : http://www.overclocking.es

16
3lr0n
Re: data from custom user fields on forums
  • 2009/5/5 22:23

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


any help?
Spanish Overclocking Community xoops based site : http://www.overclocking.es

17
mboyden
Re: data from custom user fields on forums
  • 2009/5/6 19:14

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


The problem is that you'll get errors trying to access something that doesn't exist. So, if you're access the xoopsUser variable but it doesn't exist, it will be problematic. I wrote up an article about making information available in Smarty that isn't otherwise there. Read through that and see if it gives you an idea how to proceed. This is specifically one that tests to see if the user is a registered user or not before trying to access the XOOPS user variable. Check it out.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

18
trabis
Re: data from custom user fields on forums
  • 2009/5/6 23:22

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


<{php}>
$from 'something';
$this->assign('from'$from);
<{/
php}>
<{
$from}>

19
3lr0n
Re: data from custom user fields on forums
  • 2009/5/7 6:49

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


something?..

sty but dont understand this :(
Spanish Overclocking Community xoops based site : http://www.overclocking.es

20
trabis
Re: data from custom user fields on forums
  • 2009/5/7 12:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


After this line:
$from = $profile->getVar('user_from');

you need to assign it to template with:
$this->assign('from', $from);

Login

Who's Online

314 user(s) are online (260 user(s) are browsing Support Forums)


Members: 0


Guests: 314


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits