Forums / Setup & design / Help please :-) with fetch user --> group

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

eZ debug

Timing: Jan 19 2025 15:12:06
Script start
Timing: Jan 19 2025 15:12:06
Module start 'content'
Timing: Jan 19 2025 15:12:06
Module end 'content'
Timing: Jan 19 2025 15:12:07
Script end

Main resources:

Total runtime0.1380 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.9766180.8281
Module start 'content' 0.00680.0069 769.8047106.0391
Module end 'content' 0.01360.1243 875.8438534.2500
Script end 0.1379  1,410.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.6487200.0002
Check MTime0.00141.0417200.0001
Mysql Total
Database connection0.00070.476810.0007
Mysqli_queries0.094568.48151410.0007
Looping result0.00130.92471390.0000
Template Total0.124089.810.1240
Template load0.00080.551410.0008
Template processing0.123289.267510.1232
Override
Cache load0.00060.402010.0006
Sytem overhead
Fetch class attribute can translate value0.00090.676710.0009
XML
Image XML parsing0.00020.159510.0002
General
dbfile0.00513.6662200.0003
String conversion0.00000.005030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0005 secs