We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I would need some clarification about Ditto’s doc, about "Any MODx field or TV for weighted random".

    How do I define a weight and set it ?
    Do I "just" use &filter with &randomize=`1` ?

    I sure could use an example smiley


    randomize

    Purpose : Randomize the order of the output

    Options
    0 off
    1 on Any MODx field or TV for weighted random

    Default
    0 off
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 25663 MODX Staff
      • 12,272 Posts
      I think 1 just does a 1-to-1 selection from all the options, and a TV name means use the value in that TV for the weighting (should be an integer). E.g.:

      Page 1: Ditto_weight TV -- 10
      Page 2: Ditto_weight TV -- 1
      Page 3: Ditto_weight TV -- 1
      Page 4: Ditto_weight TV -- 2


      Page 1 would show up 10x more frequently, and Page 4 2x... Pages 2,3 show up once. Theoretically. I’m probably wrong. tongue (I think it should say "1 or Any MODx field or TV for weighted random" ... possible typo?)
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 6726
        • 7,075 Posts
        Intuitively what I thought it would be, makes sense indeed, I’ll give this a try thanks Ryan !
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 25663 MODX Staff
          • 12,272 Posts
          Please report back if our collective guess was right. tongue
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 6726
            • 7,075 Posts
            Of course I will, didn’t get the chance yet !
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l'outil id
              • 2299
              • 62 Posts
              OK, I guess David was working on my website when he created this topic. It seems we never find the solution to our problem, so here I am, trying again ! smiley

              So the situation is exactly the one described by David : I want to sort documents, using weighted random. I created for this purpose a TV, in which I indicated the weight of each document.

              TV’s name : poids_banniere

              Ditto call : [!Ditto? &parents=`242` &display=`1` &randomize=`[*poids_banniere*]` &tpl=`tpl_bannieres` &noResults=` ` &showPublishedOnly=`1` &hideFolders=`1` !]

              But it doesn’t work, the same document keeps appearing. Can anyone see what’s wrong ? David mentionned the &filter parameter, but I don’t understand how it would help...

              Thanks a lot !