How to fetch user by id in template ?!

Author Message

Selmah Maxim

Wednesday 06 August 2003 9:13:53 am

Hi ..

I need to get user data by user id in template how can I do this ?
fetch('user',55') this not work .. any idea ?!

Selmah Maxim

Wednesday 06 August 2003 9:24:59 am

just checked kernel\user\function_definition.php .. there is just current_user :(

Jerry Jalava

Wednesday 06 August 2003 12:50:55 pm

I think you have to make your own module for it...
You could do alot more with that module also.

Regards,
Jerry

Terry Grossman

Friday 16 July 2004 12:34:43 pm

Hey Folks,

I found this answer to the exact question I wanted to ask, but it's been a year and I wanted to know if the answer is still "you can't do this"

Any help is appreciated

Terry

Paul Borgermans

Friday 16 July 2004 2:06:00 pm

The user id is just the content object id, so use fetch (content,object,...)

http://ez.no/ez_publish/documentation/reference/data_fetching/content/object

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Leif Arne Storset

Thursday 13 July 2006 5:23:15 am

Paul, the problem is that the fetch function you suggest fetches an ezcontentobject object, not the ezuser object. It seems that a custom fetch function would be the way to go.

Leif Arne Storset

Leif Arne Storset

Thursday 13 July 2006 7:57:30 am

How silly I am. Every user class has an ezuser attribute. By default, it is named user_account. Thus, to get the ezuser object with ID 785, simply do this:

{def $user=fetch( 'content', 'object', hash( 'object_id', 785 ) ).data_map.user_account.content}

(It's pretty cool that the eZ template language can interpret dotted function output, something PHP - the underlying "programming" language - cannot!)

Leif Arne Storset

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.