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

    i use multiple menus in my site and i want to be able to build those menus ordered by a menu-index.
    Now i want a TV that renumbers each value on change just like the real menu-index.
    So if an existing resource with myindex = 3 is changed to myindex=2, i want index2 to become 3 etc.

    is there a snappy MODx way of doing this?

    RDG

    This question has been answered by rdaneeel. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I'm not sure if Wayfinder can order by a TV. pdoMenu can.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 24629
        • 370 Posts
        Hi Susan,
        I'm not going to use it with wayfinder. I'll write my own snippet to build the menus.
        I just don't know how to make a TV that re-orders across all resources that have it, exactly like menu-index does.
        RDG [ed. note: rdaneeel last edited this post 11 years, 4 months ago.]
          • 3749
          • 24,544 Posts
          Is there some reason you don't want to just use the existing menuindex field? I don't see the point of having a TV that's going to be renumbered all the time. Using the menuindex field will make for *much* faster menus and renumbering it will also be faster. The values will persist as long as you don't drag resources in the tree.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 24629
            • 370 Posts
            Hi BobRay,

            Oh I do use the menuindex for the regular menu. but i use several kinds of menus for different collections. So a resource can be listed in several menu's. I'm looking for a way to give resources multiple menu-indices.

            RDG
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You might be able to do something with a MIGX grid. You can get the raw JSON and process it yourself, or you might be able to use migxLoopCollection. [ed. note: sottwell last edited this post 11 years, 4 months ago.]
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 3749
                • 24,544 Posts
                It's not difficult to set the TV values. The difficult part is selecting the resources you want to renumber them for, and creating an algorithm to renumber them. You haven't said how you want them ordered -- they have to be renumbered by some characteristic of the resource unless you want them in random order. The menuindex field is ordered by the resource's position in the tree, but you must not want that or you'd just use the menuindex.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  And that's why I was thinking of a MIGX grid. You can populate a grid using some code to list a specified set of resources - those with a parent of xyz, or those using a specified template. Then you can position them in the grid by dragging-and-dropping, and using the resulting TV value (JSON) to display the resources in the desired order.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 3749
                    • 24,544 Posts
                    Is there anything you can't do with MIGX? wink That sounds like a great solution.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 24629
                      • 370 Posts
                      Hi,
                      what i want is a TV on each resource called 'top10' . when my client takes a resource and fills in the input field for 'top10'
                      lets say they change rank from 2 to 5, i want the rank for the resource that has 'top10' =5 to change to 4 , resource with 'top 10'=4 to 3 etc. when i save the resource.

                      I don't see how this could be done with with MIGX?

                      I was thinking of doing this with a plug in that onBeforeDocFormSave grabs all resources with TV 'top10'
                      then checks the old value for the TV
                      then shift all values according to the new value for the TV
                      then save all resources and then go on to onDocFormSave.
                      BUt i have no idea how to even start doing this

                      RDG