We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9133
    • 17 Posts
    For me it is not very clear. This is what I read when I open the so-called "phpMyAdmin"

    mysql5-1

    * Server version: 5.0.68-log
    * Protocol version: 10
    * Server: mysql5-1 via TCP/IP

    phpMyAdmin - OVH

    * MySQL client version: 5.0.32
    * Used PHP extensions: mysql
      • 9133
      • 17 Posts
      Nobody to help me to solve this problem ?
        • 16278
        • 928 Posts
        I think several people have been trying to help! Maybe we should follow Einstein’s advice, and make everything as simple as possible (but no simpler) to begin with, and build up from there. That is, start a new document with a very basic Ditto call and check that you can get it working with the default parameters, then add the custom requirements one by one? Then you will know at what point things are failing. wink

        So your new test document might have a Ditto call:
         [[Ditto? &parents=`1` ]] 

        This is already an improvement (or an indication of true disaster if it doesn’t produce anything), because it uses the current version’s "start document" parameter &parents. You should see your items listed with the default template, including the creation date ("createdon") in a format such as 20-Mar-09 13:56.

        Looking good? Then you can move on to test that MySQL agrees with you on how to set the order, to satisfy Ryan’s curiosity:
         [[Ditto? &parents=`1` &orderBy=`createdon ASC`]]

        Produces same docs in ascending order of creation date, if all is well.
        Next step is to try a different built-in date and format it. Here it is, using the "editedon"
        field (you can easily update that by opening and resaving one of your document set).
         [[Ditto? &parents=`1` &dateSource=`editedon` &orderBy=`editedon ASC` &dateFormat=`%d %b %y`]] 

        Try this out, and let us know how you get on. BTW, you may be using out of date documentation. The most useful roundup of Ditto documentation I’ve found was by posted by MyfriendscallmeBill; it’s attached to save hunting for it in the forums or the wiki.

        Nil desperandum embarrassed
        KP
          • 9133
          • 17 Posts
          Thank you very much kp52 ! Your clear, informative and friendly way to reply is highly appreciated. Of course, I am aware that other people have tried to help. I think this is wonderful ! The only thing is that my problem had no solution yet.

          Up to the point ("editedon") you suggested it works ! Now the question is whether it will work also with a custom date (dateArticle). Will you be so kind again as to helping me further?
            • 16278
            • 928 Posts
            OK, here goes with Phase 2 of the great adventure: make sure the TV will work, get the template to match the parameters and fix some things in the Ditto call.

            Your TV needs to let you input a date, and must output the date as a Unix timestamp. This is achieved by setting its Input Type to Date, and specifying the Widget as Unixtime. You’ll now get a date-picker in the document editing screen, showing the chosen date in readable form such as DD-MM-YYYY HH:MM (some of the details are surplus to your needs, but can be ignored). The widget will translate what’s stored in the database to a Unix timestamp, as required for Ditto’s date functions. My Ditto call uses a TV called pkDate for a set of items contained in document 186:
             [[Ditto? &parents=`186` &dateSource=`pkDate` &orderBy=`pkDate DESC` &dateFormat=`%b %Y`]] 

            Now you should be getting the month-year date display of the TV as required, so we can update the template. The one in your original post was using [+dateArticle+] for the date placeholder - this needs to be [+date+], to match up to the &dateSource parameter in the Ditto call. The placeholder for the Summary text is [+introtext+], not [+summary+], which explains the non-display of that one. So the template now reads:
             <div class="ditto_documentInfo"><strong> [+date+]</strong> </div> 
            
            <div class="ditto_item" id="ditto_item_[+id+]">  
            <h3 class="ditto_pageTitle">[+pagetitle+]</h3>  
            
            <div class="ditto_introText">[+introtext+] <a href="[~[+id+]~]">More</a></div></div>
            

            and the Ditto call is
             [[Ditto? &parents=`186` &dateSource=`pkDate` &orderBy=`pkDate DESC` &dateFormat=`%b %Y` &tpl=`etDitto`]] 

            Finally, you were using some obsolete parameters for Ditto. The setting for "number to show per page" is now &display, not &summarize. We’ve already sorted out &startID and &sortBy. &total defaults to "all" anyway. I don’t think you need &extenders - it is there to support the [+summary+] placeholder we just replaced. (Documentation on Ditto 2.1 parameters is at http://ditto.modxcms.com/files/snippet-ditto-php.html). So the full Ditto call, with the start document, TV and template names and pagination parameters as per original, now reads:
             [[Ditto? &parents=`1` &display=`5` &tpl=`DittoTemplate` &paginate=`1` &paginateAlwaysShowLinks=`1` &orderBy=`dateArticle DESC` &dateSource=`dateArticle` &dateFormat=`%B %y`]] 

            Note that the call is now uncached - I found that the pagination didn’t work with an uncached call. Which illustrates one reason I’m happy to help you - I always learn something myself from the experience! laugh
            KP
              • 9133
              • 17 Posts
              The phase 2 of the adventure has brought quite a progress, thanks to you kp52 : the sorting by date works !

              But the adventure is not finished for new problems have occured: the date shown is invariably for all articles "Jan 70" and the pagination does not work. I cannot go to the next page. Apparently it works in your tests, but not in mine. The question is why.
                • 9133
                • 17 Posts
                smiley The pagination works also now. I had not understood how and where to uncach the call.

                The problem that remains is the declaration of the date.
                  • 16278
                  • 928 Posts
                  If the sorting by date is working, that should mean that the &orderBy part of the call is OK, and that the data is correct (you presumably know the correct order from the content of the articles).
                  A display of "Jan 70" (or "1 Jan 1970" when you format for a full date) indicates that a zero or an invalid value is being supplied as the timestamp. As long as &orderBy is working OK, I would suspect a typo or wrong case in the &dateSource parameter. Can you copy in your current Ditto call and template? Also you could try adding in &debug=`1` again, and have a look at the output by clicking on "Open debug console". This gives a comprehensive picture of what Ditto is seeing and what it is doing with it.
                  laugh
                  KP
                    • 9133
                    • 17 Posts
                    Hello again kp52. Thanks for being so dedicated.

                    Here are the codes:

                    [[Ditto? &parents=`1 &display=`5`  &tpl=`DittoTemplate` &paginate=`1` &paginateAlwaysShowLinks=`1` &orderBy=`dateArticle DESC` &dateSource=`dateArticle` &dateFormat=`%B %Y` &extenders=`summary` &debug=`1`]] 
                    
                    <div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div> 


                    and

                    <div class="ditto_documentInfo"><strong> [+date+]</strong> </div> 
                    
                    <div class="ditto_item" id="ditto_item_[+id+]">  
                    <h3 class="ditto_pageTitle">[+pagetitle+]</h3>  
                    <div class="ditto_introText">[+summary+] … <a href="[~[+id+]~]">More</a><br /></div></div><br />
                    


                    I kept the extenders ’summary’ for it fits better my purpose.
                      • 16278
                      • 928 Posts
                      I tried substituting your Ditto call and template in my test page (with my own &parents and TV name), and it works for me, despite the fact that &parents is missing the closing back-apostrophe! So perhaps it is the template variable that needs fixing - are you sure you have the Unixtime widget selected? I got January 1970 for every date when I set the TV to have no widget, with sorting more or less correct (I have several items close together in date).
                      Also, check the Ditto debug console Prefetch Data tab. If the TV is set up correctly, it will have a 10-digit number (e.g. 1211926564 was in May 2008) as its value in the debugger. If it’s showing a date like 2009-03-30, the widget is probably not selected.
                      You could also try making a new article - if that shows the date correctly while others keep to Jan 1970, you may need to go back over old documents and reset their dates to get the correct values into the TV fields stored in the database.
                      laugh
                      KP