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.

eZ debug

Timing: Jan 29 2025 23:50:49
Script start
Timing: Jan 29 2025 23:50:49
Module start 'layout'
Timing: Jan 29 2025 23:50:49
Module start 'content'
Timing: Jan 29 2025 23:50:50
Module end 'content'
Timing: Jan 29 2025 23:50:50
Script end

Main resources:

Total runtime1.0811 sec
Peak memory usage4,096.0000 KB
Database Queries75

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.2500151.2266
Module start 'layout' 0.00460.0023 739.476636.6641
Module start 'content' 0.00691.0733 776.1406627.0938
Module end 'content' 1.08020.0009 1,403.234415.8438
Script end 1.0811  1,419.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00280.2630160.0002
Check MTime0.00120.1124160.0001
Mysql Total
Database connection0.00070.062810.0007
Mysqli_queries1.035095.7287750.0138
Looping result0.00070.0686730.0000
Template Total1.050097.120.5250
Template load0.00180.165620.0009
Template processing1.048296.956320.5241
Template load and register function0.00010.011010.0001
states
state_id_array0.00100.094510.0010
state_identifier_array0.00130.117020.0006
Override
Cache load0.00140.1316320.0000
Sytem overhead
Fetch class attribute can translate value0.00070.063550.0001
Fetch class attribute name0.00100.091090.0001
XML
Image XML parsing0.00170.156550.0003
class_abstraction
Instantiating content class attribute0.00000.0018100.0000
General
dbfile0.00190.1740230.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs