We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41187
    • 4 Posts
    I am just in the middle of building a new website with the latest version of ModX and I have noticed that new resources require 2 saves. I have done some digging and have found out the below:


    • It only happens with friendly URLs enabled, so it is obviously something to do with this.
    • It only happens when I create a resources the long way. If I create a resource using the 'Quick Create' feature, it works fine.
    • After one save, I can access the resource fine using the ID, but when I try and use the friendly URL link, it just comes back with nothing.
    • After a second save, it works perfectly as expected.

    I have a few sites on 2.2.x on the same server and it happens to all of them. The server runs cPanel. I also have another cPanel server that I have been using with ModX for years and the same is happening with ModX 2.2.x.

    Any help would be greatly appreciated, as I am rather at wits end with this!!

    Thanks
    Alex [ed. note: ginzola1 last edited this post 14 years ago.]
      • 3749
      • 24,544 Posts
      There is a bug in recent versions where the "Empty Cache on Save" checkbox is not checked for new Resources on the Settings tab of the Create/Edit Resource panel.

      Saving it the first time doesn't clear the cache, so it appears that it wasn't saved. The second time, it's no longer a new Resource so the checkbox is checked.

      Could that be it?


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        That would do it; the cache is important for the friendly URL handling, while the basic index.php URL will work anyway since it just uses the resource ID.

        With friendly URLs, MODx is given the alias, and has to map the alias to the resource ID. If the map in the cache isn't refreshed when a new resource is created, that new alias isn't there, so you get the Not Found page.
          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
          • 41187
          • 4 Posts
          Ahh, that would be it! Thanks for clearing that up for me.

          But now I have the problem of trying to fix it! I presume it will be fixed in the next release, but where is the php file that defines this so I can fix it myself for the time being?

          Thanks Again
          Alex
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Just keep in mind that you need to check the box when creating a new resource. You soon enough get into the habit.
              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
              The fix is here: https://github.com/modxcms/revolution/commit/b82eea23dac17c120600e1da32be0cd835fb6e59


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                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
                Would't it be better if it were a system setting, like the others?
                  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
                  Actually (if I'm understanding you), the others are resource fields. I think the idea is that it should almost always be set, but you might want to change it temporarily just for the current resource.


                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html
                    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
                    Ok, I see your point. Just looking at the code, it looked a little lonely all by itself!
                      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
                      • 34178
                      • 212 Posts
                      If we uncheck "Empty cache" of a resource and save the resource and afterwards reload the resource the "Empty cache"-flag is checked by itself again.

                      Is this a bug or a feature?

                      Is there any way to change this flag per default as unchecked in the settings for all resources? Does anybody of the developers can help at this point?

                      Letti