How can find a user groups grandparent?

Author Message

Brendan Pike

Thursday 28 October 2004 2:40:02 am

How can I find the grandparent of a users usergroup? I did find the below article but I wasn't able to convert it for my need. Any help much appreciated.

http://ez.no/ez_publish/documentation/incoming/how_to_find_the_parent_and_grandparent_of_an_object

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Hans Melis

Thursday 28 October 2004 3:17:37 am

Hi Brendan,

The article you linked to takes a rather large detour to find the grandparent of a node. The following code snippet should give you the grandparent:

{$node.parent.parent}

If you want the object, it's similar to accessing the object of the current node

{let grandparent=$node.parent.parent}
  {$grandparent.object|attribute(show)}
{/let}

hth

Hans
http://blog.hansmelis.be

Brendan Pike

Thursday 28 October 2004 5:53:09 am

Thanks Hans
Doesn't work for me though, I'm inside the edit_attribute.tpl This works for me

group_id=$current_user.contentobject.main_parent_node_id

But this is only the parent not grandparent of course. Any other ideas?

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Hans Melis

Thursday 28 October 2004 8:38:33 am

Aha, you want it directly for a user. You need an additional fetch then.

{let parentNode=fetch('content','node',hash('node_id',$current_user.contentobject.main_parent_node_id))
     grandparent=$parentNode.parent}
{$grandparent.name|wash}
{/let}

Once you have a node, it's similar to what I wrote in my first reply. If you have an object (like $current_user.contentobject), then you need to find a node first.

Hans
http://blog.hansmelis.be

Brendan Pike

Thursday 28 October 2004 9:03:27 am

Nope your code still didn't work for me :(
Just got the following errors,
Unknown template variable 'parentNode' in namespace ''
Unknown template variable 'grandparent' in namespace ''
The mystery continues

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Hans Melis

Thursday 28 October 2004 9:07:48 am

You're using a namespace then. Try using $: instead of just $ in front of the variables.

Hans
http://blog.hansmelis.be

Brendan Pike

Thursday 28 October 2004 9:27:17 am

Yup your right, think I'd better go to bed.

Works nicely now, many thanks :-)

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

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

Main resources:

Total runtime0.0181 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.2734152.6406
Module start 'layout' 0.00560.0033 741.914139.4609
Module start 'content' 0.00880.0072 781.375097.4453
Module end 'content' 0.01600.0021 878.820338.3047
Script end 0.0181  917.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002614.2306140.0002
Check MTime0.00115.9931140.0001
Mysql Total
Database connection0.00094.911710.0009
Mysqli_queries0.003016.440830.0010
Looping result0.00000.088210.0000
Template Total0.00179.210.0017
Template load0.00094.999910.0009
Template processing0.00084.143810.0008
Override
Cache load0.00063.507610.0006
General
dbfile0.00169.077980.0002
String conversion0.00000.050140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

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

Time used to render debug report: 0.0001 secs