We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ 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.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 28042 ☆ 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.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 33337
        • 3,975 Posts
        Hi cryptomancer !

        Please choose topic title related to your problem, and describe your problem in efficient manner that makes sense to reader, so we can approach to you with the solution efficiently ! smiley

        regarding this, I modified the topic title and hopefully Sottwell already helped you get yourself around with it.

        best regards,

        zi
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 6048
          • 27 Posts
          Quote from: sottwell at Nov 22, 2005, 05:34 AM

          Change that ’createdon’ to ’menuindex’ and you should be all set as far as sorting goes.

          Thanks, i did it - but i’d better set the date of creation or publication, so i may have an option: leave it at current moment (default) or set to any date in past or future.

          Remembering all the time to set anything, either ’menuindex’ or ’publication date’ is BAD, but editing ’createdon’ is unavailable, and editing ’pub. date’ not works for me sad((
            • 28042 ☆ 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 cool
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 6048
              • 27 Posts
              Quote from: sottwell at Nov 23, 2005, 04:08 AM

              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  cool

              Hm, i think another way:
              1) Add ’sort_by’ field to ’content’ table, settable from Manager.
              2) Sort by this in all showing routines.
              3) Set publication date to present time and/or creation date - auto or by button.
              4) Ditch the javascript date setting in Manager, change it to plain field.

              P.S. I don’t dare to edit the code i’m not familiar with, to avoid adding even more bugs.
                • 13577
                • 302 Posts
                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.
                  • 18397
                  • 3,250 Posts
                  Jason and I worked on this in another thread.

                  Result:

                  http://modxcms.com/forums/index.php/topic,1432.msg9688.html#msg9688

                  Unfortuanately we discovered a limitation in the current API that prevents inline IF’s.

                  So, until the API is updated, Jason and I put out a version of NewsListing that has the features you wanted to impliment but minus the API (We used a direct SQL statement).

                    • 13577
                    • 302 Posts
                    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.