We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17717
    • 433 Posts
    Hi all,

    I am using ditto to display a list of articles, I am unable to get my articles to display the most recent first. Here is the structure I have in place for this section within the backend:

    Articles
    - Archived
    (no articles placed here yet)
    - Latest
    (Article 1)
    (Article 2)
    (Article 3)
    (Article 4)

    In the main Articles folder’s document content window I have added the following:

    [[Ditto? &startID=`10`&descendentDepth=`1` &sortBy=`createdon` &sortDir=`ASC`]]

    I have just added &sortBy=`createdon` &sortDir=`ASC` as above to try and get it to work but it didn’t seem to work.

    I may also need advice on how the archiving system works, it seems to automatically archive my articles, the problem is, it seems to put the most recent in the archive... very strange. Ideally, I would like to have it set up so that the latest 5 articles is placed in the Latest Articles folder and the rest gets placed in the archived. Not sure if ditto/modx can do that - place content in other folders based on a head count within its current folder.... would be VERY cool if it could, otherwise, I had hoped to just moved the oldest article (of the 10) to the archive folder manually, not the end of the world.

    Sorry for the long post folks.

    Thanks
    Lee
      http://www.blend.uk.com | Web Design by Blend
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Try sorting DESC.
        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
        • 17717
        • 433 Posts
        No joy.
          http://www.blend.uk.com | Web Design by Blend
          • 17717
          • 433 Posts
          I have modified my code:


          [[Ditto? &startID=`10`&descendentDepth=`1` &sortBy=`createdon` &sortDir=`DESC` &displayArchive=`0` &summarize=`100`]]

          This is working more like I need it to now, it just means that I have to manually move the articles that I want archiving. The above code displays my latest articles, I have set it to show a summary for the first 100, I set this to 100 because I never want the archive to kick in (not until I can control it layout more - which I am looking into), I will never have more then 10 articles in the latest articles section. The 100 is set because at the minute, it will be better to display 11 articles on the page than to have the dittos archive kick in..... mainly because it is archiving the new articles.

          I am still having a problem with the latest articles going to the bottom, I have tried changing the parameters, I am still messing around with this, sure it is something in my code... somewhere.

          Thanks
          Lee
            http://www.blend.uk.com | Web Design by Blend
            • 18397
            • 3,250 Posts
            Ditto defaults to sorting by createdon and DESC. Try removing those paramaters. Additionally, you might want to do summarize=`all` so that all documents in that folder will be shown.

            Regarding automatically moving articles from one folder to another--- Ditto will not do that. Ditto is soley for displaying documents in many formats--- nothing more nothing less. smiley
              • 17717
              • 433 Posts
              Hi Mark,

              Yes, I initially didn’t have those parameters in and it didn’t work, took them back out now, very strange that it is not displaying them in the right order. I have not set a publish date for any of the articles, maybe I could try this, had hoped it would simply organise by created on... doesn’t seem to with mine, I must be doing something wrong.

              Thanks
              Lee
                http://www.blend.uk.com | Web Design by Blend