Conditional data view

Author Message

Andrew Vorobyov

Thursday 02 June 2005 2:23:42 am

There is an object "Person" - it has 2 fields - name and nickname..

I want to be able to show "name" for all Anonymous and "nickname" ONLY for logged in "Guests"..

"Person" is located in section for members only... so i can't fetch it by fetch("content","list") funcs if anonimous is browsing.

Please advise where to dig for solutions...

Thanks,
Andrew

Ɓukasz Serwatka

Thursday 02 June 2005 3:24:36 am

Hi Andrew,

You can use simple fetch

  {def $user=fetch( user, current_user )}
  
  {* if Anonymous show the name *}
  {if eq( $user.contentobject.id, 10 )}
      {$user.contentobject.name}
  {else}
      {$user.contentobject.data_map.nickname.data_text}
  {/if}

Should works if nickname is text line datatype. For < 3.6 you should use section insted of if and let insted of def

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

Andrew Vorobyov

Thursday 02 June 2005 3:52:52 am

Thanks Lukasz..

but it means to share "content","read","Section(Memebers)" role for anonymous, right?

I don't want it!..

Because objects will be vurnerable for /content/view/full/plain/{node}
/content/view/full/full/{node}
/content/view/full/pdf/{node}

and who-knows-how-many variations to read object...

So my question now sounds like that:

<b>Any other options how to fetch fields from the objects with some kind special "admin_fetch('content'...)"

Only share section with "content","read" permission for anonymous group?
</b>

maybe any other ideas how to arrange sections?

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

Main resources:

Total runtime0.6350 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9141152.6250
Module start 'layout' 0.00740.0026 740.539139.4453
Module start 'content' 0.01000.6237 779.9844538.9453
Module end 'content' 0.63370.0013 1,318.929712.4844
Script end 0.6350  1,331.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4673160.0002
Check MTime0.00120.1879160.0001
Mysql Total
Database connection0.00150.231810.0015
Mysqli_queries0.581991.6311570.0102
Looping result0.00050.0817550.0000
Template Total0.606395.520.3031
Template load0.00200.309920.0010
Template processing0.604395.156720.3021
Template load and register function0.00010.017610.0001
states
state_id_array0.00070.113410.0007
state_identifier_array0.00110.178620.0006
Override
Cache load0.00160.2454280.0001
Sytem overhead
Fetch class attribute can translate value0.00070.109320.0003
Fetch class attribute name0.00100.164840.0003
XML
Image XML parsing0.00080.123320.0004
class_abstraction
Instantiating content class attribute0.00000.001840.0000
General
dbfile0.00140.2220180.0001
String conversion0.00000.001040.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/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: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs