We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30884
    • 142 Posts
    Hi there, happily working away using ditto 2.1 on Modx 0.95 (updated some elements of it till I upgrade to 0.96/7).

    I managed to be able to sort on a TV called start_date which only started working when I cleared the widget on the TV to not be Unix Timestamp. No problems, just a little conflict on the ditto docs example.

    I do have various job vacancy articles with same start dates but want to be able to sort on a secondary tv to the start date so I can organise the order of apperance for a raft of vacancies which will have the same start date for example. I’ve tried &sortBy=`start_date,priority` and in the debug console it does show the two tvs as being called but it’s not sorting on either of them when I try that.

    Is there something I’m missing?

    Any advice (or pointing out the blindingly obvious!) is much appreciated!

    Cheers

    TxRx

    update: The only tv retrieved is the start_date tv. The Backend does list the priority tv but doesn’t seem to be acting on it.

      p i x e l p u s h e r e x t r o d i n a i r e
      A x i s A n i m a t i o n . c o m
      • 7231
      • 4,205 Posts
      &sortBy=`start_date,priority`
      I think in Ditto it is orderBy. Try this:
      &orderBy=`start_date,priority`

      Edit, never mind, sortBy seems to be correct.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 30884
        • 142 Posts
        Tried that but it presents a MySQL error when I try that!
        Most weird.

        Seems it’s an internal variable:
        http://ditto.modxcms.com/files/snippet-ditto-php.html#orderBy
          p i x e l p u s h e r e x t r o d i n a i r e
          A x i s A n i m a t i o n . c o m
          • 7231
          • 4,205 Posts
          I see. It is in the newer documentation and sortBy is not, but in the older docs sortBy is mentioned and orderBy is not. By looking at the class you seem to be right, the sortBy is the way to go.

            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 30884
            • 142 Posts
            Looks like it. Maybe he’s revising sortBy or depreciating it in the next update. For now I’ll get by. Thanks for the reply!

            cheers

            TxRx
              p i x e l p u s h e r e x t r o d i n a i r e
              A x i s A n i m a t i o n . c o m
              • 7231
              • 4,205 Posts
              I think that sorting by date may disable the multisorting feature. Ditto seems to have a hierarchy when it comes to sorting methods.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 18397
                • 3,250 Posts
                There is a bug in the 2.1.0 release that dealt with the new multisort. Give the development version a try and &orderBy=`start_date,priority` should work. However, remember Ditto will sort based on the numeric values of start_date and only move to priority if the start_date values are the same.
                  • 30884
                  • 142 Posts
                  That sounds perfect, I’m using Unix timestamps for the TV values so they’ll be ok I’d imagine. I’ll give the development version a try laugh

                  Many thanks Mark!

                  Cheers

                  TxRx
                    p i x e l p u s h e r e x t r o d i n a i r e
                    A x i s A n i m a t i o n . c o m
                    • 10313
                    • 375 Posts
                    Quote from: Mark at Apr 15, 2008, 08:54 PM

                    There is a bug in the 2.1.0 release that dealt with the new multisort. Give the development version a try and &orderBy=`start_date,priority` should work. However, remember Ditto will sort based on the numeric values of start_date and only move to priority if the start_date values are the same.

                    I just tried the current development version, but I receive a MODx error with this snippet call:
                    [!Ditto? &display=`all` &language=`german` &tpl=`dittoKontakt` &orderBy=`qfThema,qfMarke` &showInMenuOnly=`1` &parents=`13` !]


                    The error is a MODx pareser error caused by wrong mysql syntax:
                    SQL: SELECT DISTINCT sc.id,sc.published FROM `db164144`.`modx_site_content` sc LEFT JOIN `db164144`.`modx_document_groups` dg on dg.document = sc.id WHERE sc.id IN (14,15,33,34,35,36,37,38,39,40) AND sc.published=1 AND sc.deleted=0 AND sc.hidemenu = 0 AND (sc.privateweb=0) GROUP BY sc.id ORDER BY sc.id qfThema, sc.id qfMarke 


                    The error is in the "ORDER BY". both qfThema and qfMarke ar template variables. Is it possible at all to order by TV?

                    Martin
                      • 18397
                      • 3,250 Posts
                      Are you sure you updated all of the files to Ditto 2.1 development version (see link in signerature)? Also, do the TVs already exist and have content?