Problem with: sort_by

Author Message

Siw Helen Thorslund

Wednesday 25 May 2005 9:30:14 am

I have a site where it's a listing of news.

I now use:

sort_by, $node.sort_array,

This works fine, but my customer wants to keep a couple of articles on top for a while.

This we could solve with sorting by priority, and give the two articles a higher value than 0. But the problem is that the rest og the articles with the value 0 are by default sorted the wrong way I want the newest first, following the two top articles.

Any of you know how to sort the articles with the value 0 the other way?
Or do any of you have a better solution?

(The customer wants to be able to do this sorting theirselves in the future too.)

www.VZT.no ( http://www.VZT.no )
VZT References ( http://http://vzt.no/index.php/vzt_eng/referanser )
VZT Extensions ( http://vzt.no/index.php/vzt_eng/extensions )
www.MediaBase.no ( http://www.MediaBase.no )

Luke Barton

Wednesday 25 May 2005 11:43:46 am

Consider this.

You could add an attribute to each article that controls its "override sort key" value.

For instance, all articles would default sort by date (or whatever you're already doing).

Then, if the user wishes to set the override sort value for a few articles, the user can set them in the order they wish:

override_sort_val = 1
override_sort_val = 2

You template logic would then search for override_sort_val first, and sort by the attribute value.

Then, your logic would sort the rest by your default sort key.

The user would be responsible for setting the override_sort_val to zero when that article was no longer controlled by override.

Hope this helps or sparks some more ideas.

-Luke

Marko Žmak

Wednesday 25 May 2005 4:59:30 pm

Or you could (without creating
override_sort_val attribute) fetch first the articles that have priority > 0 and sort them by any criterium you want. And then fetch all the rest and sort THEM also by any criterium you want.

It's easier, and convenient because priority can be updated in the admin interface in the listing.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.