eZ Community » Forums » Developer » DISTINCT filter on a fetch function
expandshrink

DISTINCT filter on a fetch function

DISTINCT filter on a fetch function

Thursday 28 June 2012 10:21:10 am - 3 replies

Hello,

I've fetched all users drafts on the Draft Dashboard module.

So, users must duplicate the last version of the draft to add their own modifications.

The problem is that on the Drafts module, we can see all the versions fetched (with the same title).

Can I filter the draft fetch telling it to sort drafts by distinct title or distinct ID ?

 

Thanks for your help !

Modified on Thursday 28 June 2012 10:24:52 am by Arnaud Cabrolier

Thursday 28 June 2012 11:10:11 am

HI.

Since your other  post states that you are moving the 'choice' of drafts to the versionview screen(table of versions - where one can duplicate a draft), there are two ways to achieve this based on your approach:

1 - in your template, you can always change the loop in the display logic to suppress duplicates.

2 - If you are using eZPersistentObject::fetchObjectList() as part of a custom fetch, some of the options include sort(param 4) and grouping(param 7) - so you should be able to affect what you need by adjusting your parameters on to fetchObjectList to sort and group appropriately.

But keep in mind, different draft versions may have been created for various reasons - especially with multiple languages and things can get messy in a busy situation if there is no logic to 'smartly' manage the drafts for people in this situation.  Take, for example 3 people involved in your scenerio and perhaps 3 languages - creating a new version for themselves to edit.  Versions stack up quickly and you may  hit the max version limit of the content class. And since you cannot delete drafts belonging to others, this could become a bit of a mess.  Then again, if this is just a situation of a few people who play well together and the drafts are delete when not needed, you may be OK. 

Regards,

David 

Thursday 28 June 2012 3:08:35 pm

Thanks David !

Concretely, I've tried to do a distinct filter on the fetch but when I refresh my list, no changes...

It doesn't work...='(

Have you got an idea ?

Thanks !

 array( 'length' => $limit, 'offset' => $offset ),
 array( 'distinct' => $objectID ),

Modified on Thursday 28 June 2012 3:17:50 pm by Arnaud Cabrolier

Friday 29 June 2012 2:38:27 pm

Quote from Arnaud Cabrolier :

Thanks David !

Concretely, I've tried to do a distinct filter on the fetch but when I refresh my list, no changes...

It doesn't work...='(

Have you got an idea ?

Thanks !

 array( 'length' => $limit, 'offset' => $offset ),
 array( 'distinct' => $objectID ),

 

 

HI.

This is based on the fetch in your other post and groups by contentobject_id:

 

        $draftVersionList =  eZPersistentObject::fetchObjectList( 
                                                                   eZContentObjectVersion::definition(),
                                                                   false,
                                                                   array('status' => eZContentObjectVersion::STATUS_DRAFT ),
                                                                   array('version' => false ),
                                                                    null,
                                                                   true,
                                                                   array('contentobject_id')
                                                                   );

 

Because you then pass people to another page for choosing the draft, the version number is irrelevant anyway.
Remember: this gives you draft objects and not content objects as used in the 'My Drafts' dashboard template and not actual content objects.

Hope this helps.

 

 

 
expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from