We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2989
    • 13 Posts
    Hi

    Trying to get Ditto to sort on the menuindex [!Ditto? &tpl=`tplMenuIndex` &orderBy`menuindex`!]
    It doesn’t seem to help.
    The goal is to have it sort the document tree in the order they are and any change in the order will affect the output.

    Any help appreciated.

    /Becher
      • 36582
      • 463 Posts
      What version of ditto are you using?
        Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
        • 2989
        • 13 Posts
        Hi

        I’m using 1.0.3
          • 36582
          • 463 Posts
          You should update to the latest compatible version if your install allows - if not then use:

          [!Ditto? &startID=`##` &tpl=`tplMenuIndex` &sortBy=`menuindex`!]

          If you upgrade ditto to 2.0 or above then that would become:

          [!Ditto? &parents=`##` &tpl=`tplMenuIndex` &orderBy=`menuindex`!]

          or

          [!Ditto? &documents=`##,##,##` &tpl=`tplMenuIndex` &orderBy=`menuindex`!]

          Where ## are your parents or documents.

          Hope that helps.
            Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
            • 2989
            • 13 Posts
            Ah sorry, thought you meant the MODx version, which is 1.0.3.
            My Ditto ver is 2.1.0
              • 2989
              • 13 Posts
              orderBy gives this error:

              « MODx Parse Error »
              MODx encountered the following error while attempting to parse the requested resource:
              « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’menuindex’ at line 4 »
              SQL: SELECT DISTINCT sc.published,sc.id,sc.pagetitle FROM `modx`.`modx_site_content` sc LEFT JOIN `modx`.`modx_document_groups` dg on dg.document = sc.id WHERE sc.id IN (45,47) AND sc.published=1 AND sc.deleted=0 AND (sc.privateweb=0) GROUP BY sc.id ORDER BY sc.id menuindex
              [Copy SQL to ClipBoard]

              Parser timing
              MySQL: 0.2535 s (14 Requests)
              PHP: 0.1515 s
              Total: 0.4050 s
                • 36582
                • 463 Posts
                Try:

                [!Ditto? &parents=`##` &tpl=`tplMenuIndex` &orderBy=`menuindex ASC`!]
                  Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
                  • 2989
                  • 13 Posts
                  Thx for answering

                  Thought i don’t see it helping sorting the tree as expected.
                  Any help?
                    • 36582
                    • 463 Posts
                    I take it you are entering figures in the Menu Index field? eg 1 for the top item and say 10 for the bottom item?

                    When you say ’sorting the tree’ I take it that you are talking about the output and not in the Manager?
                      Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
                      • 2989
                      • 13 Posts
                      Yes precisely, i’m setting the "menu index" numbers in each item in the document tree.
                      Normally this is done automatically when you create a document.
                      BUT, if i want to change it myself having it to output a different "sorting" list, i doesn’t work.

                      Ex.
                      Name A (index 0)
                      Name B (index 1)

                      change it manually to
                      Name B (index 0)
                      Name A (index 1)

                      the output doesn’t come out right...