-
☆ A M B ☆
- 24,524 Posts
Hm. You must be using the original version; I was referring to the updated version. In any case, the relevant line reads:
$resource = $modx->$callby($resourceparent, 'createdon', 'DESC', $fields='id, pagetitle, description, introtext, content, createdon, createdby, hidemenu');
Change that ’createdon’ to ’menuindex’ and you should be all set as far as sorting goes.
And yes, it does lack the "ORDER BY", that is in the class DB API that the snippet uses.
-
☆ A M B ☆
- 24,524 Posts
Quote from: cryptomancer at Nov 22, 2005, 05:33 AM
P.S. IMHO the info about content ordering pertains to content itself too, and once set in Manager should be retained across all and any front-end routines. Lack of such a behavior is definitely a design flaw - i found no field like ’sort_by’, or does it exist anyway ?
Flexibility is never a flaw. It is up to the snippet programmer to choose what fields to order the content by. Most news and blogs want their items ordered by entry, beginning with the most recent. As I mentioned before, it would be a trivial matter to add another option argument to NewsListing to allow the user to select the field to sort by. The default would reasonably continue to be ’createdon’, since that is the most common usage.
-
☆ A M B ☆
- 24,524 Posts
Well, that’s reasonable...creation date really should be just that, the date it was created. As far as the publish date, that’s not really what it’s for. That is only for when an unpublished document should be published (holiday article, for example, written in July but you don’t want it published until after Thanksgiving); ditto unpublish date.
As soon as I get finished with the blog site tutorial, I’ll add the options "&sortBy" and "&sortDir"
to the NewsListing snippet; unless somebody else beats me to it
A query piece I often like to use is
...ORDER BY IF(pub_date>0, pub_date, createdon) DESC...
Which says if pub_date exists, order by that, but if not, then use the created on date. That way if I write a story to be published immediately, it goes by the current (createdon) date. If I **actually plan ahead** and have a story publish date, it will use that instead. Pretty slick.
Standard Disclaimer
I could be totally wrong.
Well there you have it. My stubborn nature had me skipping right over the API and writing my own SQL (which works fine in MODx). Who knew...
Standard Disclaimer
I could be totally wrong.