We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20042
    • 10 Posts
    I deleted a page, but I still want to use that Page ID. When I create a new page it automatically uses the next page ID. How can I manually set the Page ID of the new page? Can I edit existing Page IDs?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The page IDs are the autoincrement values when inserting a new document into the database. You should edit them only if you are really confident in working directly with the database.
        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
        • 20042
        • 10 Posts
        Which tables reference the Page ID?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, that’s why it’s usually not a good idea to mess around with those, because TVs are tied in with them. I’m not sure what else.
            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
            • 20042
            • 10 Posts
            Ok, I understand it’s tricky.....does anyone have any actual information?
              • 2734
              • 165 Posts
              Actually, the changing of the id itself is not that hard. A simple query to the Database will do:
              UPDATE `modx_site_content` SET id=(old id) WHERE id=(new id)


              Since modx does not use foreign keys for tables (compatibility reasons i guess), the changing of the ID will – as sottwell pointed out – have a lot of consequences. To really change the id in a clean manner, you’ll have to change all other DB entries that are linked to this id as well. This starts with the "parent" field inside the modx_site_content Table and extends to a lot of other tables (modx_site_metatags, modx_document_groups, the document groups and access permissions and so on).

              Changing this single id could become quite a cumbersome task. I’d rather fix this by redirect the old id to the new one with a .htaccess Rewrite Rule or something similar.
                • 20042
                • 10 Posts
                I understand that you’ll need to change it in the other DB tables as well. I was hoping someone had a list of which tables use it. Oh well, guess I’ll just go through all the tables and find out myself.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Then maybe you could post your findings in the Wiki under Tips wink
                    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
                    • 2734
                    • 165 Posts
                    Quote from: ganeshXL at Dec 05, 2007, 10:28 AM

                    UPDATE `modx_site_content` SET id=(old id) WHERE id=(new id)
                    


                    Actually, it’s the other way around:
                    UPDATE `modx_site_content` SET id=(new id) WHERE id=(old id)
                    


                    Umm, no. He wants his OLD id back, thus he wants to replace the new id with the old one.
                    But yes.. this could cause confusion. It should say
                    UPDATE `modx_site_content` SET id=(desired value) WHERE id=(current value)