Display info depending on Usergroup

Author Message

John Kazakis

Friday 04 April 2008 6:01:44 am

Hello,

I'm trying to display different information depending on the usergroup of current_user.

The issue that I'm running into is that every user is part of the "Users" usergroup, so I can't seem to be to use {case match='Anonymous'}.

Here's the code that I'm using;

{foreach $user.groups as $key => $group}
	{def $group=fetch( 'content', 'object', hash( 'object_id', $user.groups[$key] ) )}

{let groupn=$group.name}

{switch name=pagetester match=$groupn}

{case match='IE07'}

        				<p>You are a member of: <strong>IE07</strong><br />
				You have access to the following sections:
				<ul>
					<li>Access to this</li>
					<li>and that</li>
				</ul></p>

{/case}

{case match='UE2'}

<p>You are a member of UE2</p>

{/case}

{case in=array(Anonymous, Users)}
			<p> You are an anonymous user.<br />
				You do not have access to this section, If you'd like to have access, please <a href="/publications/subscribe">click here</a>.
{/case}

{/switch}
{/let}
{/foreach}

This works only for anonymous, but when I log in as one of the other users, it doesn't seem to work. I am using {switch} because there will be about 10 usergroups.

John Kazakis

Monday 07 April 2008 4:57:22 am

Looks like I fixed this,

Used an if statement instead, so my code looks like this now

			{if $group.name|contains( IE07 ) }
				<p>You are a member of: <strong>Import/Export 2007</strong><br />
				You have access to the following sections:
				
 	 		{elseif $group.name|contains( UE2 )}
  				<p>You are a member of: <strong>UEII</strong><br />
				You have access to the following sections:	
			{elseif $group.name|contains( Anonymous )}
				<p> You are an anonymous user.<br />
				You do not have access to this section.

...

One thing I'd like to add is to display a message depending on the current node that the user is in. Is it possible? I've read about $requested_uri_string, but it seems it's only for pagelayout. Is there another way?

Thanks.

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 19:39:04
Script start
Timing: Jan 18 2025 19:39:04
Module start 'layout'
Timing: Jan 18 2025 19:39:04
Module start 'content'
Timing: Jan 18 2025 19:39:05
Module end 'content'
Timing: Jan 18 2025 19:39:05
Script end

Main resources:

Total runtime0.8223 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.9375152.6250
Module start 'layout' 0.00680.0036 740.562539.4453
Module start 'content' 0.01040.8104 780.0078427.5625
Module end 'content' 0.82080.0015 1,207.57038.1563
Script end 0.8222  1,215.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4372160.0002
Check MTime0.00140.1711160.0001
Mysql Total
Database connection0.00140.173510.0014
Mysqli_queries0.777094.4955520.0149
Looping result0.00050.0650500.0000
Template Total0.783395.320.3916
Template load0.00210.256520.0011
Template processing0.781295.000220.3906
Template load and register function0.00020.025110.0002
states
state_id_array0.00220.273510.0022
state_identifier_array0.00210.260020.0011
Override
Cache load0.00170.2075150.0001
Sytem overhead
Fetch class attribute can translate value0.00050.055110.0005
Fetch class attribute name0.00100.125120.0005
XML
Image XML parsing0.00010.013410.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00070.0873100.0001
String conversion0.00000.001140.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/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: 10
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs