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.