We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    I have a page which has a ditto call to sort its articles by date. What I’d like to do is have an alternative way to sort its articles (ie: sort by title/author,etc) in the sidebar without creating another page.


    IE:
    "My offers" <- A page which has the following Ditto call;

    <!-- This ditto call is on the page, and not in the template -->
    [[Ditto?! &dateSource=`pub_date` &dateFormat=`%b %d, %Y` &sortBy=`pub_date` &sortOrder=`DESC` &display=`all` &startID=`48` &summarize=`5` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`OfferList`]]
    


    In the sidebar I would like to have an option to change the sortBy field to ’author’ or a template variable (ie: ’price’), or any other field I might want.

    I’m wondering - is there a way to use a variable in a hyperlink to tell Ditto how to sort its pages, rather than creating yet another page? Can Ditto understand how to parse variables destined for the sortBy field?

    ie:
    [[Ditto?! &dateSource=`pub_date` &dateFormat=`%b %d, %Y` &sortBy=`{{SomeVariable}}` &sortOrder=`DESC` &display=`all` &startID=`48` &summarize=`5` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`VanList`]]
    


      • 10449
      • 956 Posts
        • 32645
        • 377 Posts
        http://ditto.modxcms.com/extenders/request.html

        Thanks for your help - but I am unclear on how to get started with this - it says to add the parameters to the URL, but which URL is it talking about?

        Is it all a question of adding "&ditto_something" to the ditto call? Its not clear about this.

        Also, if there’s an example of how to implement this, via a ditto call, etc that’d be great.
          • 10449
          • 956 Posts
          I don’t think there’s anything more to add than what’s mentioned in the article.

          The URL is of course the URL of the page where this Ditto call resides.

          e.g.
          http://www.example.com/index.php?id=97&ditto_sortBy=mytvname&ditto_sortDir=DESC
          or, when using alias/friendly-URLs:
          http://www.example.com/helloworld.html?ditto_sortBy=mytvname&ditto_sortDir=DESC

          I don’t know what Ditto does when you omit those GET parameters. Maybe define default values in case there’s no query string.
            • 32645
            • 377 Posts
            Hi.

            Sorry - its still not working - maybe I’m doing something wrong.

            Ditto call;
            [[Ditto?! &dateSource=`pub_date` &dateFormat=`%b %d, %Y` &sortBy=`pub_date` &sortOrder=`DESC` &display=`all` &startID=`48` &summarize=`5` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`OfferList` &extenders=`request` &id=`offer-list`]]
            



            URL;

            http://URL/PAGE/?ditto_id=offer-list&ditto_sortBy=tv_price&ditto_sortOrder=asc

            That does nothing - its always ordered in date descending fashion. Cache is off on the page - so this should not be affecting the page.

            (edited because url parameters were incorrect)
              • 32645
              • 377 Posts
              In the wiki, it says to use a unique ID &id= however, if you use this it causes conflicts with pagination - sometimes pagination links completely disappear.

              I think I’ll just use a different approach - even if it means using another page to resolve this.
                • 20845
                • 5 Posts
                I think it’s a MySQL issue.

                Refer to the discussion I started here..

                http://modxcms.com/forums/index.php/topic,22716.0.html
                  • 18397
                  • 3,250 Posts
                  Quote from: worchyld at Feb 13, 2008, 09:47 AM

                  In the wiki, it says to use a unique ID &id= however, if you use this it causes conflicts with pagination - sometimes pagination links completely disappear.

                  When using &id and pagination you need to update your pagination placeholders to the format [+id_placeholder+].

                  Also, if you have &id and the request extender, the variables in the URL need to be in the format ditto_DITTOID_ instead of ditto_.
                    • 32645
                    • 377 Posts
                    Okay - I will try this.

                    Many thanks.
                      • 32645
                      • 377 Posts
                      Quote from: Mark at Feb 13, 2008, 06:08 PM

                      Quote from: worchyld at Feb 13, 2008, 09:47 AM

                      In the wiki, it says to use a unique ID &id= however, if you use this it causes conflicts with pagination - sometimes pagination links completely disappear.

                      When using &id and pagination you need to update your pagination placeholders to the format [+id_placeholder+].

                      Also, if you have &id and the request extender, the variables in the URL need to be in the format ditto_DITTOID_ instead of ditto_.

                      Hi,

                      I’ve got the url changing the sorting part -- but the pagination is still blank.


                      // This changes the sorting fine.
                      index.php?id=XX&ditto_id=vlist&ditto_vlist_sortBy=tv_price&ditto_vlist_sortDir=desc

                      With regards to changing the placeholder --

                      http://ditto.modxcms.com/tutorials/pagination.html gives no example of how to change the placeholder to the format [+id_placeholder+]

                      Is it just a case of adding &id_placeholder to your ditto call?