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.