Help please :-) with fetch user --> group

Author Message

danny36 danny36

Wednesday 27 October 2004 2:46:17 am

I need to display the name of the group the user belongs to.
I try to use:

{let utente=fetch( 'user', 'current_user' )}
{$utente.groups[0]}
{/let}

but i obtain only the object_ID of the group.

<b>Is there a way to obtain the name of the group??</b>

Thank you very much

danny36 danny36

Wednesday 17 November 2004 6:50:34 am

anyone can help me?

Łukasz Serwatka

Wednesday 17 November 2004 6:53:25 am

Hi

Try use

{$utente|attribute}

to view all attributes

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

danny36 danny36

Wednesday 17 November 2004 7:16:58 am

yes but this show all attributes of user included the subarray group, but how can i access to the attribute of this sub array?

Łukasz Serwatka

Wednesday 17 November 2004 7:20:47 am

Use this

{let utente=fetch( 'user', 'current_user' )}
{$utente.contentobject.id}

{let group=fetch( 'user', 'member_of',
       hash( 'id', $utente.contentobject.id ) )}

{$group[0].name}

{/let}

{/let}

{$group} is a array so you can use {section} to view all groups for curren user

it works but i think that is a simple way to fetch user group

P.S
Please edit your last post, it`s too long ;-)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

danny36 danny36

Wednesday 17 November 2004 7:49:36 am

I found this code snippet in the documentation:

{let user=fetch( 'user', 'current_user' )}
   User:     {$user.contentobject.name}<br />
   Email:    {$user.email}<br />
   Login:    {$user.login}<br />
   Group(s): {$user.groups|implode(', ')}<br />
{/let}

the code show me this result:

User: Anonymous User
Email: nospam@ez.no
Login: anonymous
Groups: 42

but is still show the Object ID of "anonymous" group, how can i access of attribute "name" and "description" of class "group" that can i found in the "classes" link in admin site?

Bruce Morrison

Thursday 18 November 2004 2:09:05 pm

Once you have the object id(s) of the group(s) you can fetch them just like any other object using

{let utente=fetch( 'user', 'current_user' )
     group=fetch( 'content', 'object', hash( 'object_id', $utente.groups[0] ) )}

Group name: {$group.name}
{/let}

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

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Norman Leutner

Thursday 29 December 2005 10:23:01 pm

For fetching and displaying the groups of the current user you can use:

{def $user=fetch( 'user', 'current_user' )}

{foreach $user.groups as $key => $group}
{def $group=fetch( 'content', 'object', hash( 'object_id', $user.groups[$key] ) )}
  User is Member of: {$group.name} <br/>
{/foreach}

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

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 18 2025 21:08:50
Script start
Timing: Jan 18 2025 21:08:50
Module start 'layout'
Timing: Jan 18 2025 21:08:50
Module start 'content'
Timing: Jan 18 2025 21:08:52
Module end 'content'
Timing: Jan 18 2025 21:08:52
Script end

Main resources:

Total runtime1.4075 sec
Peak memory usage4,096.0000 KB
Database Queries76

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 587.9375152.6250
Module start 'layout' 0.00490.0027 740.562539.4453
Module start 'content' 0.00761.3984 780.0078698.6953
Module end 'content' 1.40600.0014 1,478.703120.1406
Script end 1.4074  1,498.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2263160.0002
Check MTime0.00140.0982160.0001
Mysql Total
Database connection0.00090.060610.0009
Mysqli_queries1.333194.7182760.0175
Looping result0.00070.0524740.0000
Template Total1.378898.020.6894
Template load0.00220.153020.0011
Template processing1.376797.811520.6883
Template load and register function0.00010.007110.0001
states
state_id_array0.00090.060610.0009
state_identifier_array0.00170.122920.0009
Override
Cache load0.00180.1285490.0000
Sytem overhead
Fetch class attribute can translate value0.00070.052540.0002
Fetch class attribute name0.00090.0646120.0001
XML
Image XML parsing0.00210.146340.0005
class_abstraction
Instantiating content class attribute0.00000.0023160.0000
General
dbfile0.00110.0780370.0000
String conversion0.00000.000540.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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs