Forums / Setup & design / Filter and sort mixed content class

Filter and sort mixed content class

Author Message

Olivier Pierret

Tuesday 08 February 2005 4:55:13 am

Hello

I am managing to set up the "news" section of a site. Basically, this section should gather all object whose attribute "is_new" has been set to true, sorted by last publish date.

The problem is that the function fetch( 'content', 'list',... doesn't support filtering on different content classes. So I don't know how to initially retrieve this "news" object list.

Of course I could make a specific call to fetch( 'content', 'list',... for each content class. In this case I would be back in my template with several tables (one by class type actually). I could merge these tables together and then display the list but how can sort these content objects together by publish date? I did not see any sort operator that would do the job easily...

Does someone have any idea on how to solve these problems?

Thank you in advance

Olivier Pierret

PS: If I am not clear enough I can elaborate a bit ;)

Arran Price

Tuesday 08 February 2005 10:31:44 am

Hi Olivier,
You mention using 'list' rather than 'tree' in your fetch so does that mean you are only looking for content in one folder?

I wouldnt class my self as very experienced with ezpublish but heres a few ideas off the top of my head.

Fetch all results and only display the ones that have the is_new set.
eg

{section show=$item.whatever.is_new|eq(true)}
   <p>some code to display whatever I want</p>
{/section}

Without testing - I dont know what the actual syntax for $item....is_new is..

Do what you were intending with the fetch per class but change the way you display it, ie group the items in the way you display them so you dont have to worry about merging your arrays etc (although if you do merge the arrays successfully I would love to see the code you use).
your output could be something like:
New Articles:
article1
article2

New Files:
file1
file2

etc

Hope thats of some help

Arran

Olivier Pierret

Wednesday 09 February 2005 8:19:26 am

"Hope thats of some help" :)

That is exactly the answer I needed. Already in place and working... Thank you so much.

Well... actually I feel a bit stupid now...

Olivier