We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32365
    • 42 Posts
    I’m wondering if there’s a way to get ditto to sort a call by the first letter of a TV to create an A-Z sortBy system.

    I looked into the "Site A to Z" snippet, and even though it listed an a-z search, I couldn’t get it to tie in with my existing ditto call smoothly.

    I’m using URL links to change the parameters of the ditto call(?ditto_sortBy=name for example) and I am unsure how to add the filter parameter(http://ditto.modxcms.com/files/snippet-ditto-php.html#filter) into a URL call or even if it can be.

    Ideally I would like to use mode 11("checks leading character of the field" which would be "name" from above for example) and only show pages that’s leading "name" character is "a" for example.
      • 1122
      • 209 Posts
      The following code
      [[Ditto? &parents=`3,4,5` &display=`all` &tpl=`@CODE:<p>[+pagetitle+]</p>` &filter=`pagetitle,S,11` &sortBy=`pagetitle` &sortDir=`ASC`]]
      

      displays all documents within 3, 4, and 5 containers whose titles start with "S" letter. Simply adjust it for your needs.
        • 32365
        • 42 Posts
        Quote from: alik at Nov 30, 2009, 08:33 AM

        The following code
        [[Ditto? &parents=`3,4,5` &display=`all` &tpl=`@CODE:<p>[+pagetitle+]</p>` &filter=`pagetitle,S,11` &sortBy=`pagetitle` &sortDir=`ASC`]]
        

        displays all documents within 3, 4, and 5 containers whose titles start with "S" letter. Simply adjust it for your needs.
        Alright that’s working the way I want when I put it into the ditto call like above, but I can’t get it to work through a URL link. These are the formats I’ve tried;
        ?ditto_filter=name,I,11
        
        ?filter=name,I,11
        


        Do you know what I’m doing wrong/is there another way to dynamically change the ditto paramters from the live webpage?
          • 1122
          • 209 Posts
          Of course, I know. You cannot put a parameter into a URL and hope that it will work. Altering Ditto’s parameters via URL requires an appropriate extender. Try this:
          [[Ditto? &parents=`3,4,5` &display=`all` &tpl=`@CODE:<p>[+pagetitle+]</p>` &filter=`pagetitle,S,11` &sortBy=`pagetitle` &sortDir=`ASC` &extenders=`request`]]
          

          Now you can change parameter by adding to your URL ?ditto_filter=... Good luck!
            • 32365
            • 42 Posts
            Quote from: alik at Nov 30, 2009, 02:20 PM

            Of course, I know. You cannot put a parameter into a URL and hope that it will work. Altering Ditto’s parameters via URL requires an appropriate extender. Try this:
            [[Ditto? &parents=`3,4,5` &display=`all` &tpl=`@CODE:<p>[+pagetitle+]</p>` &filter=`pagetitle,S,11` &sortBy=`pagetitle` &sortDir=`ASC` &extenders=`request`]]
            

            Now you can change parameter by adding to your URL ?ditto_filter=... Good luck!
            Alright it’s working grin. Thank you for the assistance. I already had the &extenders=`request` code in, but it turns out the reason it wasn’t working the first time was because I only refreshed the page and for some reason that was causing the error.

            After I reloaded the page through the navigation links(not just loading it from "preview resource" as I have been doing) it started working.

            I’m slowly piecing this site together, I got a form that a user fills the fields in that creates pages than then only that user can edit(from another form that loads). And now I almost got the browsing system finished. Next is to read up on the "date" T.V. input type to and keep tracks of the dates and times new pages are created for a "browse by date" ditto search as well.

            I do have one last question though, if I wanted to add in a link to show only pages that begin with numbers, how would I format it to show 0-9?

            Like this?
            ?ditto_filter=name,0-9,11
              • 1122
              • 209 Posts
              I’m afraid that such multiple selection (docs whose names start with 0-9) cannot be done with Ditto’s filter. The reason for this is a way in which Ditto’s filter behaves. We need to keep in mind that filter EXCLUDES documents. Filter like "name,A,11" means: exclude all documents whose name does not start with "A". Of course, we can try multiple filter like "name,0,11|name,1,11|name,2,11|...", but it will always lead to empty result set due to the mentioned internal logic of Ditto’s filter -> in first step it excludes docs whose name does not start with "0" and in the second it excludes docs whose name does not start with "1" (actually, it excludes all docs that were selected in the first/former step). Multiple selection needs something custom-designed.
                • 32365
                • 42 Posts
                Alright, thank you for all the assistance anyway. The 0-9 isn’t that important. If I can’t find a solution I’ll just set it to re-list all pages in DESC order so that numbers come first anyway.