Forums / General / Fetching different classes with common attribute

Fetching different classes with common attribute

Author Message

Ted Striker

Monday 26 July 2004 8:00:20 am

Is it possible to filter two different classes that have a common attribute?

Lets say that we have different instances of an "article" class and some other of a "interview" class, with a common "date" (not publish date) attribute in the same foilder:

article/date
interview/date

Is it poossible to filter both classes and order them by this common attribute? Should I only use a single class in avery folder?

TIA

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.

Roy Bøhmer

Tuesday 27 July 2004 1:23:40 am

The short answer is no!
Even if the identifiers are the same, ez sees them as two completely different attributes. (They've got their own attribute-id). When you define filter you either use the attribute-id or specifies which class you use (article/date). As far as I know it NOT possible to write

fetch(content, list, ...., 
    attribute_filter('or', 
                     array('article/date','<',current_date()),
                     array('interview/date','<',current_date())
                     ....)

My advice is to always do a class_filter when you're doing a attribute_filter.
A tip could be to do one fetch for articles and one for interviews, and afterwards combine the two arrays into one usin append. http://ez.no/ez_publish/documentation/reference/template_operators/arrays/append
The problem with this metod is that it is hard to do a proper sort across the classes.

By the way:
There is one advantage by giving your attribute the same identifiers: You can reuse template-code.

Roy

Bruce Morrison

Thursday 29 July 2004 4:20:02 pm

Hi Roy

> My advice is to always do a class_filter when you're doing a attribute_filter.

I'm pretty sure that I've found these to be mutually exclusive as one implies the other.
See: http://ez.no/community/forum/developer/using_attribute_filter_on_related_object_attributes

Have you had success?

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

Andrew Vorobyov

Monday 13 June 2005 4:10:01 pm

I can't access in attribute_filter ezdate attribute by name

This works:

array(268,'>=',makedate(1,1,sub($today.year,$params.ageto)

This does NOT work:

array('class_name/ez_date_attr_name','>=',makedate(1,1,sub($today.year,$params.ageto)