We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8822
    • 203 Posts
    Hi, does anyone know how to sort the results of getImageList by a TV value? I am trying to sort the results by the 'date' TV, but to no avail. By default it displays them in the order they were entered (latest last), but i want to be able to control this, or at a minimum reverse the order? I currently have:

      							[[!getImageList? 
        							&tvname=`recommendations`
    								&sortBy=`date`
    								&sortDir=`desc`
    		  						&tpl=`@CODE:<li><h3>[[+name]]</h3>
    								<p class="datefacebook">[[+date]], <a href="[[+facebook]]" target="_blank">[[+facebooktext]]</a></p>
    								<p>[[+recommendation]]</p></li>
      							`]]
    


    Thanks for your help!
      • 22840
      • 1,572 Posts
      According to the docs &sort should work

      http://rtfm.modx.com/extras/revo/migx/migx.frontend-usage

        • 8822
        • 203 Posts
        Hi Paul, i tried that but couldn't get it to work either. Not sure i got the syntax quite right though:

        [[!getImageList? 
            							&tvname=`recommendations`
        								&sort=`{"sortby":"[[+date]]","sortdir":"DESC"}`
        		  						&tpl=`@CODE:<li><h3>[[+name]]</h3>
        								<p class="datefacebook">[[+date]], <a href="[[+facebook]]" target="_blank">[[+facebooktext]]</a></p>
        								<p>[[+recommendation]]</p></li>
          							`]]
        
          • 22840
          • 1,572 Posts
          Hi Emily,

          To be honest I've never used it so am only guessing but have you tried:


          [[!getImageList?
                &tvname=`recommendations`
                &sort=`[{"sortby":"date","sortdir":"ASC"}]`
                &tpl=`@CODE:<li><h3>[[+name]]</h3>
                <p class="datefacebook">[[+date]], <a href="[[+facebook]]" target="_blank">[[+facebooktext]]</a></p>
                <p>[[+recommendation]]</p></li>
                `]]
            • 8822
            • 203 Posts
            Yep smiley

            Tried all variations and none of the below seem to work at all....

            &sort=`[{"sortby":"[[+date]]","sortdir":"ASC"}]`

            &sort=`{"sortby":"[[+date]]","sortdir":"ASC"}`

            &sort=`[{"sortby":"date","sortdir":"ASC"}]`

            &sort=`{"sortby":"date","sortdir":"ASC"}`
              • 4172
              • 5,888 Posts
              this should do it:

              &sort=`[{"sortby":"date","sortdir":"ASC"}]`


              whats your output with:
              [[*recommendations]]

              ?

                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 8822
                • 203 Posts
                Hi, thanks for you response. Unfortunately though it doesn't work. Does that sort by the system date though or the date entered in the TV (date)? I want it to sort by the TV date....

                Using [[*recommendations]] does not display the TV content, whilst [[+recommendations]] does display the TV content - was that what you asking!?
                  • 4172
                  • 5,888 Posts
                  [[*recommendations]] 


                  should display the TV-content. Or are you using it inside a getResources-tpl?

                  It does sort by the MIGX-field 'date' then.
                  But let me see your TV-content, please.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 45642
                    • 2 Posts
                    Hi Bruno, i think i've the same problem as Emily. I am trying to sort the results by the 'migxdate' TV but nothing works.

                    This is what i have:

                     
                    [[!getImageList?
                    		&tvname=`woordenschatje`
                    		&tpl=`woordenschatje_overzicht_tpl`
                    		&sort=`[{"sortby":"migxdate","sortdir":"ASC"}]`
                    ]]
                    


                    And the TV content

                    [{"MIGX_id":"1","migxdate":"1383817156","woord":"test1","betekenis":"test1","voorbeeld":"test1"},{"MIGX_id":"2","migxdate":"1383817162","woord":"test2","betekenis":"test2","voorbeeld":"test2"}]
                    


                    Thanks in advance!
                      • 4172
                      • 5,888 Posts
                      Tested this just now:

                      [[getImageList? 
                       &sort=`[{"sortby":"migxdate","sortdir":"ASC"}]`
                       &value = `
                      [
                      {"MIGX_id":"1","migxdate":"1383817156","woord":"test1","betekenis":"test1","voorbeeld":"test1"},{"MIGX_id":"2","migxdate":"1383817162","woord":"test2","betekenis":"test2","voorbeeld":"test2"},{"MIGX_id":"3","migxdate":"1383817144","woord":"test2","betekenis":"test2","voorbeeld":"test2"}]`
                       &tpl=`@CODE:[[+migxdate]],`
                      ]]
                      


                      seems to work. This is the result:

                      1383817144,1383817156,1383817162,
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!