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)

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

Main resources:

Total runtime0.6485 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.0391152.6406
Module start 'layout' 0.00490.0022 740.679739.4766
Module start 'content' 0.00710.6398 780.1563626.7422
Module end 'content' 0.64690.0015 1,406.898412.1250
Script end 0.6485  1,419.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.5012160.0002
Check MTime0.00150.2249160.0001
Mysql Total
Database connection0.00080.116310.0008
Mysqli_queries0.592191.2942640.0093
Looping result0.00070.1097620.0000
Template Total0.619395.520.3097
Template load0.00210.329520.0011
Template processing0.617295.167520.3086
Template load and register function0.00010.016110.0001
states
state_id_array0.00130.201510.0013
state_identifier_array0.00090.138520.0004
Override
Cache load0.00180.2802350.0001
Sytem overhead
Fetch class attribute can translate value0.00090.137140.0002
Fetch class attribute name0.00120.190860.0002
XML
Image XML parsing0.00130.194140.0003
class_abstraction
Instantiating content class attribute0.00000.003660.0000
General
dbfile0.00100.1601220.0000
String conversion0.00000.001140.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/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: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs