How to display the user image

Author Message

Pascal France

Sunday 28 May 2006 12:29:31 pm

Hi,

I would like to display the user image (the one which admin can upload when he creates a new user).
I found this post:
http://ez.no/community/forum/general/user_image
and tried the given solution without success.

{$user|attribute(show)} doesn't display any image attribute.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Friday 26 May 2006 8:23:37 am

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Marcin Drozd

Sunday 28 May 2006 4:06:37 pm

Hi Pascal
Which user?
user who is currently logged in or owner of current object? mayby all users?

if you want to display image of current user:

{def $user=fetch( 'user', 'current_user' ) }
{if $user.data_map.image.has_content}
   {attribute_view_gui attribute=$user.data_map.image image_class=small}
{/if}
U have to be logged in (anonymous has not a photo)
(U can use {if $user.is_logged_in} too)

if U want to display owner' image:

{def $owner=$node.object.owner $owner_map=$owner.data_map}
{if $owner_map.image.has_content}
{attribute_view_gui attribute=$owner_map.image image_class=small}
{/if}
{undef}

for all users use:

{def $users=fetch( 'content', 'list', hash(parent_node_id, USERS_GROUP_NODE_ID) ) }
{foreach $users as $user}
 {if $user.data_map.image.has_content}
   {attribute_view_gui attribute=$user.data_map.image image_class=small}
 {/if}
{/foreach}

http://ez-publish.pl

Pascal France

Sunday 28 May 2006 11:58:11 pm

Hi Marcin,

Yes, it is the image of the logged user I want to display.
I don't know why, but:

{def $user=fetch( 'user', 'current_user' )}
{if $user.is_logged_in}
 {attribute_view_gui attribute=$user.data_map.image image_class=small}
{/if}

does not return anything.

As I told in my first post, {$user|attribute(show)} doesn't display any "image" attribute, then I think "data_map.image" can't work.

The admin interface uses this template:
design/admin/templates/content/edit.tpl
which includes:
design/admin/templates/content/edit_attribute.tpl
which uses this other one:
design/standard/templates/content/datatype/edit/ezimage.tpl
to display the user image in the user edit view (this line:
{attribute_view_gui image_class=ezini( 'ImageSettings', 'DefaultEditAlias', 'content.ini' ) attribute=$attribute} displays the user image).

First, I don't understand how edit_attribute.tpl calls ezimage.tpl ?
Second, I don't understand how to reuse:

{attribute_view_gui image_class=ezini( 'ImageSettings', 'DefaultEditAlias', 'content.ini' ) attribute=$attribute}

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Marcin Drozd

Monday 29 May 2006 12:41:33 am

I have found a mistake:
should be:

{attribute_view_gui attribute=$user.contentobject.data_map.image image_class=small}

and it works

http://ez-publish.pl

Pascal France

Monday 29 May 2006 12:56:02 am

Thinks a lot Marcin.

Now it works.
I looked for in the documentation but I didn't found anywhere how to do that.

Is there other attributes I can access with $user.contentobject ? How can display the list of these attributes ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Marcin Drozd

Monday 29 May 2006 1:24:49 am

Hi
U can use

{$user.contentobject|attribute(show,1)}
{$user.contentobject|attribute(show,2)}, etc.but be careful with 4, 5 !!

try with too:
{$user|attribute(show,2)}

http://ez-publish.pl

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 19 2025 01:13:37
Script start
Timing: Jan 19 2025 01:13:37
Module start 'layout'
Timing: Jan 19 2025 01:13:37
Module start 'content'
Timing: Jan 19 2025 01:13:38
Module end 'content'
Timing: Jan 19 2025 01:13:38
Script end

Main resources:

Total runtime0.7804 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1563152.6250
Module start 'layout' 0.00640.0037 741.781339.4453
Module start 'content' 0.01010.7689 781.2266558.4141
Module end 'content' 0.77890.0014 1,339.640616.1641
Script end 0.7803  1,355.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4890160.0002
Check MTime0.00150.1942160.0001
Mysql Total
Database connection0.00090.119410.0009
Mysqli_queries0.717291.9109690.0104
Looping result0.00070.0950670.0000
Template Total0.738094.620.3690
Template load0.00220.285120.0011
Template processing0.735894.288220.3679
Template load and register function0.00020.020010.0002
states
state_id_array0.00120.152110.0012
state_identifier_array0.00160.210720.0008
Override
Cache load0.00190.2486570.0000
Sytem overhead
Fetch class attribute can translate value0.00060.082120.0003
Fetch class attribute name0.00210.269970.0003
XML
Image XML parsing0.00030.033020.0001
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00070.0906100.0001
String conversion0.00000.000940.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/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: 41
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs