We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19787
    • 28 Posts
    What is the official way for the document menuindex to work. I have always used the "Doc Manager" to sort my documents and after sorting it resets the first document menuindex to 1. However, when you crete a new document with Modx it always starts at 0

    Here is an example. A list of new documents created - the menuindex value is in square brackets.

    [sub folder]
    	doc D	[0]
    	doc B	[1]
    	doc A 	[2]
    	doc D 	[3]


    after using Modules > Doc Manager > Sort Menu Items

    [sub folder]
    	doc A	[1]
    	doc B	[2]
    	doc C 	[3]
    	doc D 	[4]


    If i now add a new document to the sorted doc folder it will be assigned a menuindex of 4.

    [sub folder]
    	doc A	[1]
    	doc B	[2]
    	doc C 	[3]
    	doc D 	[4]
    	new doc	[4]


    If i move or copy a document to another section it always keeps the same menu index. I would expect Modx to automatically update the menuindex of documents if they are moved or copied but maybe this is the default behavior.

    So who is the culprit? Modx or Doc Manager? I am already having some issue with Doc Manager and updating TVs as mentioned in this post so i am guessing this might be it.

    My setup is as follows

    Modx 0.9.6.3
    MySQL 5.1.34
    Apache 2.2.8
    PHP 5.2.4

    Is there an easier method for updating all menuindexes? Something like a "Publish All" option? I use the menuindex in one of my snippets and its tedious to have to update the sort order after any editing or creating.
      • 3749
      • 24,544 Posts
      I guess you could blame either one. It looks like DocManager starts the index at one and MODx gives the new document a menu index of $count, where $count is the number of existing docs (assuming the numbering starts at 0). You could easily change either one if you could find the code.

      BTW, you probably know this, but menu indexes are arbitrary and don’t need to be consecutive. If you have a document that you want to stay at the bottom of the menu, you can give it a menu index of 9999. I’m not sure what DocManager would do with that.

      I’m not sure why you need to keep resorting your documents. If you start with menu indexes of 10, 20, 30, etc., for example, you can manually slot a new doc in where you want it. You can also leave Menu Index blank in which case (I think) the docs will be presented in the order they were created.
        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
        • 19787
        • 28 Posts
        Hi Bob, Thanks for explaining this. I am probably using menuindex for the wrong purpose.

        I am using the menundex in a custom snippet as an identifier to the documents position in the tree. The snippet allows me to output a custom layout based on the order of the documents in the tree. Eg. I have an array of all the documents and if its menuindex is 4, 8, or 12 I assign it a certain class.

        I am now thinking this is probably not the best way to do it, and maybe a count value on the items would be a better solution.



          • 3749
          • 24,544 Posts
          If you created a template variable to hold the document-specific info, you’re snippet could check that TV in creating the layoutand it would be independent from the menu index. Or, probably better yet, put the class name in the TV and just use <div class="[*TvName*] "> in your template.
            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
          • <div class="[[*TvName*]] ">
            You’re spending too much time with Revo! (should be [*TvName*])
              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
              Quote from: sottwell at Jul 15, 2009, 06:14 AM

              <div class="[[*TvName*]] ">
              You’re spending too much time with Revo! (should be [*TvName*])
              Oops. I should be more careful. smiley
              Fixed the post above.
                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
                • 33337
                • 3,975 Posts
                I think DocManager should be updated to accommodate this. please file this in JIRA.

                Thanks.
                  Zaigham R - MODX Professional | Skype | Email | Twitter

                  Digging the interwebs for #MODX gems and bringing it to you. modx.link