How to get all contentobject attributes of a certain version

Author Message

Ralph Ekekihl

Monday 23 May 2005 9:48:42 am

Hi!

I need to fetch all the contentobject attributes under a certain Classattribute, now I am doing:

$contentAttributeList =& eZContentObjectAttribute::fetchListByClassID($ID)

but this returns ALL the versions of the contentobject attributes, I only want the published versions or the latests versions!

It this possible somehow?
really thankful for some help, cause Im a bit stuck here!

Regards,
Ralph Ekekihl

Contactivity B.V.
http://www.contactivity.com

Paul Forsyth

Monday 23 May 2005 11:02:23 am

If you know what the latest version is you can pass that value as the second parameter to your function.

Can you do a version check on your object? Eg $object->attribute('current_version');

paul

Ralph Ekekihl

Tuesday 24 May 2005 3:03:28 am

Hi Paul,

The problem is, I need to get a list of all ezcontentobejcts_attributes with a certain contentclass_attributeid, in this case, all ezobjectrelation attributes.
That is why I am using

eZContentObjectAttribute::fetchListByClassID()

I only need attributes by ClassID.

Now, all objectattributes also have their own version number, but that doesnt help me in this case..or does it?

If I fetch it on a object level, I can understand how I can use (current_version), but when I fetch it on a attribute level, how can I then easily get the current version of the parent object the attribute is under?

Thanks alot Paul!

//Ralph

Contactivity B.V.
http://www.contactivity.com

Paul Forsyth

Tuesday 24 May 2005 3:16:11 am

Yes, its a static call which does return all versions.

The version of an attribute is actually tied to the content object. If the content object goes up a version so does all of its attributes.

Looking at the fetchListByClassId its a shame that you cannot pass in something that sets the 'published field.

For example, adding:

$conditions['status'] => EZ_CONTENT_OBJECT_STATUS_PUBLISHED

would do the trick.

If you cant patch the kernel then you may need to iterate on the results and make sure you only keep the latest versions which are published. Not ideal but it would work.

Paul

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

Main resources:

Total runtime0.8336 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 589.6016152.6563
Module start 'layout' 0.00680.0052 742.257839.5078
Module start 'content' 0.01200.8200 781.7656550.3125
Module end 'content' 0.83200.0016 1,332.078112.0938
Script end 0.8335  1,344.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3915160.0002
Check MTime0.00140.1621160.0001
Mysql Total
Database connection0.00130.158110.0013
Mysqli_queries0.770292.3996600.0128
Looping result0.00060.0734580.0000
Template Total0.785394.220.3927
Template load0.00220.260720.0011
Template processing0.783193.949720.3916
Template load and register function0.00010.011510.0001
states
state_id_array0.00300.362910.0030
state_identifier_array0.00230.276520.0012
Override
Cache load0.00180.2173360.0001
Sytem overhead
Fetch class attribute can translate value0.00080.099220.0004
Fetch class attribute name0.00120.148750.0002
XML
Image XML parsing0.00080.099620.0004
class_abstraction
Instantiating content class attribute0.00000.001660.0000
General
dbfile0.00120.1466160.0001
String conversion0.00000.000940.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
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs