We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3518
    • 2 Posts
    I’m having a problem using Randomize and Paginate together. The combo works fine on the first page, but when I go to the next page the page is blank.

    Here’s the Ditto code i’m using:

    [!Ditto? &startID=`7` &showPublishedOnly=`1` &randomize=`1` &summarize=`12` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`designerListing` !]
    [+pages+]

    This is the page in question: http://preflight.thefinderskeepers.com/profiles.php

    Does anybody have any ideas?
      • 4172
      • 5,888 Posts
      Its a bit tricky, but you can try this way:

      dirty description:
      you have to create a snippet ’getrandom’ which gets all documents in a random order (of course you can use $modx->runSnippet(’Ditto’,$params);for that), save this order commaseperated into a session-var.

      before you get a new random order you have to check, whether your session-var is setted, if so, do not get the documents again.
      return your commasepareted list for the ditto-parameter &documents.

      then you need a plugin, which saves last visited document also in a session-var.
      Then you can check the document where you come from. If you came from different document, unset your document-list-session-var.

      Now you can call Ditto like that:

      [!Ditto? &documents=`[[getrandom]]` &showPublishedOnly=`1` &display=`12` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`designerListing` &extenders=`documentsort` !]


      documentsort is a special extender I have coded, for not to reorder the list which comes from &documents.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 3518
        • 2 Posts
        Quote from: Bruno17 at Aug 12, 2009, 07:55 AM

        dirty description:
        you have to create a snippet ’getrandom’ which gets all documents in a random order (of course you can use $modx->runSnippet(’Ditto’,$params);for that), save this order commaseperated into a session-var.

        Thanks for your reply Bruno, and i’m sorry for my ignorance in advance, but i’m not very advanced when i comes to snippets and functions etc... i’m a pretty basic user and what you said kind of went over my head.

        You’re saying that i need to create a snippet that makes a random array of all the documents and outputs them in the ditto call?

        Can you possibly post me some code to put in the snippet?

        Thanks heaps,
        Luke
          • 4172
          • 5,888 Posts
          Here is the idea for the snippet, not tested:

          <?php
          
          if (!isset($_REQUEST['start']){
          unset($_SESSION['randomdocs'])
          }
          
          if (!isset($_SESSION['randomdocs'])){
          
          	$params=array();
          	$params['tpl']='@CODE[+id+],';
          	$params['parents']=isset($parents)?$parents:'7';
          	$params['randomize']='1';
          	$_SESSION['randomdocs']=$modx->runSnippet('Ditto',$params);	
          }
          
          return $_SESSION['randomdocs'];
          
          ?>



          create and use this ditto extender:http://modxcms.com/forums/index.php/topic,38711.msg233570.html#msg233570
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!