Monday 04 April 2011 6:31:07 am
Hakan, there are few things that should be mentioned regarding your question... 1) The best way to sort on attributes from different classes is to create an extended attribute filter that does this. 2) Using attribute filtering and sorting is something that has to be done with much caution, because produces complex SQL queries that can have serious performance impacts. Especially if you use attributes from many different classes. I had some experiences with that... 3) As I can see from your code you are trying to sort on published_date. Note that every eZP object has it's own "published" field which is not an attribute and it's the same for all objects regardless of the object's class. So you can sort ont this field like this:
'sort_by', array( 'published', false() ) Sorting on this field doesn't produce so much complex queries and is better for performance. 4) The published date I mentioned in 3) cannot be changed by editors in the eZP admin interface. And I know that sometimes there is a need for an editor to change the published date (I had similar situations). In this case a better solution is to crate an edit handler that will change this published field based on the date entered in the published_date attribute. I have made en extension that has such functionality:
- http://projects.ez.no/saedithandlers
Feel free to contact me if you need help in setting it up. 5) I noticed that you are mixing both articles and layoutblocks in the same fetch which seems like mixing apples and oranges, so maybe you should rethink this logic. Of course, I could be wrong about this one, but it's just a tought. <span class="line"> 'sort_by', array( 'published', false() </span>
--
Nothing is impossible. Not if you can imagine it!
Hubert Farnsworth
|