Using attribute_filter on related object attributes

Author Message

John Dalton

Tuesday 25 May 2004 12:04:22 am

Hi everyone,

Some background: A Gig is an event where a Band plays at a Venue. When looking at the details of a Gig, I want to be able to display a short list of all other Gigs at the same Venue, and all other Gigs featuring the same Band.

The Venue and Band are both objects, and are stored as related object attributes of a Gig.

To display a list of Gigs at the same Venue I'm using this code:

    {let venue=fetch( 'content', 'object', hash( 'object_id', $node.object.data_map.venue.data_int ) )}

    <b>More events at the {$venue.name}</b><br>
    {section loop=fetch( 'content', 'tree',
        hash(	'parent_node_id',	'46',
            'class_filter_type',	'include',
            'class_filter_array',	array( 'gig' ),
            'attribute_filter',	array( 'or', array( 'gig/venue', '=', '$venue.id' ))
    ) )}

This gives me nothing. If I remove the attribute filter I get all the gigs. What I really need to do is filter based on the object id, so using something like "gig/venue.id" in the filter, but this doesn't seem to work.

Does anyone have any ideas how I can do this?

Lazaro Ferreira

Thursday 27 May 2004 11:28:56 am

Hi,

Have you try simply

$venue

Lazaro
---
http://www.mzbusiness.com

Lazaro
http://www.mzbusiness.com

Bruce Morrison

Monday 31 May 2004 10:38:19 pm

It looks as if the class filtering and the attribute filtering are mutually exclusive (class filtering is implied by the attribute filter) so removing this should work.

{let venue=fetch( 'content', 'object', hash( 'object_id', $node.object.data_map.venue.data_int ) )}

<b>More events at the {$venue.name}</b><br>
{section loop=fetch( 'content', 'tree',
hash( 'parent_node_id', '46',
      'attribute_filter', array(array( 'gig/venue', '=', $venue.id ))
) )}

Should do the trick.

Cheers
Bruce http://www.designit.com.au

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

John Dalton

Tuesday 01 June 2004 7:08:15 pm

Thanks Bruce, and for all your help via email - this solved the problem for me. For anyone else running into the same problem, you also need to take note that your id (in the attribute_filter) shouldn't have quotes around it! Compare my original code with Bruce's example.

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 31 2025 06:11:37
Script start
Timing: Jan 31 2025 06:11:37
Module start 'layout'
Timing: Jan 31 2025 06:11:37
Module start 'content'
Timing: Jan 31 2025 06:11:38
Module end 'content'
Timing: Jan 31 2025 06:11:38
Script end

Main resources:

Total runtime0.9837 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.2813151.2266
Module start 'layout' 0.00560.0029 739.507836.6797
Module start 'content' 0.00850.9743 776.1875978.9141
Module end 'content' 0.98290.0008 1,755.101611.8125
Script end 0.9837  1,766.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3001160.0002
Check MTime0.00120.1247160.0001
Mysql Total
Database connection0.00100.097010.0010
Mysqli_queries0.931694.7017620.0150
Looping result0.00050.0540600.0000
Template Total0.953496.920.4767
Template load0.00170.169920.0008
Template processing0.951796.748920.4759
Template load and register function0.00100.104510.0010
states
state_id_array0.00100.100910.0010
state_identifier_array0.00140.143320.0007
Override
Cache load0.00140.1420260.0001
Sytem overhead
Fetch class attribute can translate value0.00040.040230.0001
Fetch class attribute name0.00180.186150.0004
XML
Image XML parsing0.00070.068230.0002
class_abstraction
Instantiating content class attribute0.00000.001050.0000
General
dbfile0.00240.2420160.0001
String conversion0.00000.000840.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs