1
BaptX
Get Uname from Uid in my own module
  • 2012/8/2 21:22

  • BaptX

  • Just popping in

  • Posts: 1

  • Since: 2012/8/2 2


Hi there,

First, i'm sorry if my question is not in the good section. Don't hesitate to move this post in the correct one. Then, i'm totaly beginner in PHP /Xoops developpment. I try to develop a module for the website of my association. Last, my english is not fluent, so i'm sorry if my explanations are bad :)

So, in order to save in database additionals informations about users, i created a new table. In order to link this table with the 'user' table, i save the uid in a column.

Now, i would to print in the admin part of my module an array with informations about all users, and the first column must be the nickname of the user.

So i created a new object which extends XoopsObject and a handler which extends XoopsPersistableObjectHandler in order to get simply datas from database. But i don't success to retrieve the uname of each user. I don't know if i need to do this in the smarty script or in my object.

I tried to do this in my class :
le="color: #000000"><?php function __construct() { $this->initVar('uid', XOBJ_DTYPE_INT, null, true); $this->initVar('member_id', XOBJ_DTYPE_INT, null, true); $this->initVar('member_lastname', XOBJ_DTYPE_TXTBOX); $this->initVar('member_website_name', XOBJ_DTYPE_TXTBOX); $handler =& xoops_gethandler('users'); $this->setVar('member_website_name', $handler->getUnameFromId($this->getVar('uid'))); }

but it is not working.

After, i tried this in my php page :
le="color: #000000"><?php $userhandler =& xoops_gethandler('user'); $GLOBALS['xoopsTpl']->assign('users', $userhandler);

and this in my smarty script :
le="color: #000000"><?php <{foreach item=member from=$members}> <tr class="<{cycle values='odd, even'}>"> <td><{$users->getUnameFromId(member.uid)}></td> </tr> <{/foreach}>

but compilation failed.

Anyone have an idea ?

Thanks in advance :)

Edit : I think it's quite difficult to find a correct way because I need to call a function from Xoops Kernel but all members are feach in the smarty script. May I have to code my own SQL request ?

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!