We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22446
    • 181 Posts
    One final question. What parameters change in the snippet if I wanted to display the ditto call for a week or a month?

    Thanks again.
      • 4172
      • 5,888 Posts
      for month its easy. Remove %d from dateformat.

      for week its not so easy.
      See modified code above.

      there are new parameters

      &mode : week, month, day is default.
      &dayoffset : together with week you can change the day of week when you want to change, 0 is sunday, default is 1 (monday)

      example:
      [[daylidoc? &parent=`13`&chunkname=`weeklydoc`&mode=`week`&dayoffset=`0`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 22446
        • 181 Posts
        okay that clears up my questions.

        Thank you again.
          • 22446
          • 181 Posts
          Bruno17,

          So I have all this parameters that you had helped me out with. I was able to get the document to display properly. Once a full 24 hours has passed the ditto call said there were no documents to display. I checked the chunk daylidoc and there is no document id to pass to the ditto call? I am not sure if I am missing something or what?

            • 4172
            • 5,888 Posts
            this could happen, if you have only one ressource. This snippet trys to show a different doc than the day before, but cannot find one. The result is an empty chunk.
            I changed the code above, which should fix this. If there is no other resource, lets the chunk and the old randomID untouched now.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 12110
              • 122 Posts
              Hello bruno,

              I just tested the daylidoc snippet, I commented out date_default_timezone_set as the site is under PHP4 still, but I’m gettimg the error

              « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY random LIMIT 1' at line 1 »
                    SQL: SELECT id,rand() as random FROM `db_xxxxx`.`modx_site_content` WHERE parent=673 AND id not IN (742,741,) ORDER BY random LIMIT 1 


              Do you think it’s due to PHP4 too, or what could be my mistake (Evo 1.0.0., Ditto 2.1.)? (db name changed to xxxxx only here).

              My Ditto call is
              [!Ditto? &documents=`[[daylidoc?&parent=`673`&chunkname=`weeklydoc`&mode=`week`&excludedocs=`742,741` ]]` &display=`1` &level=`1` &tpl=`ditto_ZitatAuszug` &sortBy=`menuindex` &sortDir=`asc` !]


              Thanks if you can help!
              Guenter
                • 4172
                • 5,888 Posts
                not IN (742,741,)


                the last comma shoutn’t be there
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 22446
                  • 181 Posts
                  So I have been doing updates to my site and basically what I am doing is removing any ditto calls on my website. I have converted my ditto call to getResources. Here is the getResources call using the daily doc. With the getResources you can pass template variables through. This makes the dailydoc snippet very useful. Thanks bruno for all your help.

                  [[!getResources? &resources=`[[daylidoc? &parent=`2`&chunkname=`daylidoc`&excludedocs=`3,149`]]` &limit=`1` &showHidden=`1` &includeTVs=`1` &tvPrefix=`` &tpl=`daily_webcam` &processTVs=`1`]]


                  Hope this helps out others.


                  Bruno17,
                  Have you thought about packaging this snippet up and making an addon for modx revolution? This is a great feature. Thank.
                    • 12110
                    • 122 Posts
                    I just changed this lines in Bruno’s dailyDoc snippet code from

                    if (is_array($chunk)){
                        	$excludedocs=isset($excludedocs)?explode(',',$excludedocs):array();
                    		$excludedocs[]=$randomDocID;
                    		$excludedocs=implode(',',$excludedocs);
                        }


                    to

                    if (is_array($chunk)){
                        	$excludedocs=isset($excludedocs)?explode(',',$excludedocs):array();
                    		$excludedocs[]=$randomDocID;
                    		$excludedocs=implode(',',$excludedocs);
                    		$excludedocs=substr($excludedocs,0,-1); // strip last comma
                        }


                    as this is removing the comma after the last id of excluded docs. Bruno pointed to this as cause of the SQL error I mentioned above.

                    Thanks again, Bruno, it’s working perfectly now for me in weekly mode.
                      • 22446
                      • 181 Posts
                      What if I wanted to display an image from a directory instead of a document in modx. Can this snippet be modified for that? Could the snippet also include a delete function that would delete the image from the folder after being display only so that it won’t be displayed again?