User

This example demonstrates how to display profiles of users on templates.

Overview anchor.png

In Legacy 2.1, you can assign XoopsUser objects to template variables. The following example explains using objects with XOOPS2 style.


 global $xoopsTpl;
 $xoopsTpl->assign('poster'$poster);

<p>Poster's name: <{$poster->getShow('uname')}>

The getShow() method returns sunitized string for html displaying. If you don't know security programming detaily, you should use this method basically.

Page Top

With the xoops_user modifier anchor.png

In the case which Legacy RenderSystem renders your templates, you can use unity modifier to display profiles by uid only.

The following example display uname of the user whose uid is 1.

<p><{1|xoops_user:uname}></p>

In other words, even if you assign XoopsUser object to template variables, you can display profiles from uid.


 class Message {
   var $title;
   var $message;
   var $poster_uid;
 }

<p><{$message->poster_uid|xoops_user:uname}></p>

This modifier equals the following code:


 $handler =& xoops_gethandler('user');
 $user =& $handler->get($message->poster_uid);
 $user->getShow('uname');


Front page   Freeze Diff Backup Copy Rename ReloadPrint View   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom) Powered by xpWiki
Counter: 14820, today: 1, yesterday: 2
Princeps date: 2007-01-12 (Fri) 03:38:14
Last-modified: 2007-01-16 (Tue) 17:39:57 (JST) (4602d) by Anonymous

Welcome | News | Overview | Documentation | Forum | Tutorialstop
Brasilian | French | German | Greek | Japanese | Korean | Russian | T-Chinese
Powered by XOOPS Cube 2001-2011 The XOOPS Cube Project