We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30051
    • 14 Posts
    Thanks!

    With that config file I get:

    PHP error debug
    Error: Invalid argument supplied for foreach()
    Error type/ Nr.: Warning - 2
    File: /srv/www/htdocs/greyamsterdam.com/modx/assets/snippets/ditto/classes/ditto.class.inc.php
    Line: 158
    Line 158 source: foreach ($orderBy[’parsed’] as $item) {


    Seems I’m using Ditto version 2.1.0

    ideas?




      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It does look to me as if you don’t have publish dates set. Are you sure that you set these for each document in the Settings tab?
        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
        • 30051
        • 14 Posts
        Yes, all three items have a date under the "published" textbox under settings tab. Published checkbox also checked.
        Resource overview confirms they are all set as well.

        in the new.config file changing to $orderBy = ’createdon’; gives me the same error

        Install new Ditto perhaps?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I have no idea at this point.
            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
            • 16278
            • 928 Posts
            If you want to use $orderBy in a config file, you have to include it in an array of sorting criteria as Ditto does when it encounters the parameter, so the config file code above would read
            <?php
            $parents = 2;
            $tpl = 'news_item';
            $orderBy = array('parsed'=>array(), 'custom'=>array(), 'unparsed'=>'pub_date DESC);
            ?>

            The alternative is to use $sortBy=’pub_date’ and $sortDir=’DESC’ as plain vanilla variables.

            What does pub_date look like if you just insert it in a document with [*pub_date*]?
            smiley KP
              • 30051
              • 14 Posts

              I see

              That change to the news.config file gives me a totally blank output

              With [!Ditto? &parents=`2` &tpl=`news_item` &orderBy=`published_on DESC` !]
              I get these pub_dates:

              1267110120
              1265111400
              1267977660


              something’s wrong?
                • 30051
                • 14 Posts
                Hey thanks for your help all.

                It doesn’t work for me we can see that - but why you think?
                Sorting by date of published really should be possible and that you actually get an error is weirdo, no?
                Seems its more likely a bug or what u reckon?

                Please advice.

                many thanks
                  • 4310
                  • 2,310 Posts
                  Are you running MySQL 5.0.51 by any chance?
                    • 30051
                    • 14 Posts
                    Nope:)

                    PHP Version 5.2.11
                    Mysql 5.0.67

                      • 16278
                      • 928 Posts
                      There does seem to be something strange here. The figures that came out for [+pub_date+] are OK in as far as they are valid Unix timestamps, which Ditto needs for sorting, but they don’t match up to the dates you mentioned previously (they convert to Feb 25, Feb 2 and March 7 2010).

                      Another thing you can try in order to pinpoint the problem is Ditto’s debug mode. Add &debug=`1` to your parameters, and you’ll get links to a table listing out what Ditto is receiving by way of data, what fields it is seeing and so on.
                      smiley KP