Forums / Setup & design / How to display the user image

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