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

    I just notices, that the name of a context is also the database key! Is there a safe way to change this key, meaning to change the name of the context?

    Thanks
    Oliver

    P.S.: Was there a reason not to use a numeric id as database key and make the "name" of the context editable? Since I like to name my contexts after my subdomains I would like to have "web" be named "www". Also I would like to have the option to correct misspelled entries after I already worked in a context. Allowing no hyphens when copying a context makes it difficult for subdomains like "the-tree".
      MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
      http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
    • There is already a feature request for this to be changed in the future.
      • Quote from: OpenGeek at Jan 18, 2011, 08:17 PM

        There is already a feature request for this to be changed in the future.

        Sounds cool! Yesterday I did some manual "search&replace" in the database which also seems to work fine. But that’s not my favorite way.

        Thanks for your replay and your great work on developing MODX!
          MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
          http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
          • 8830
          • 98 Posts
          Still nothing on this?

          /E
            • 34027
            • 30 Posts
            To rename contexts, I'm doing a manual search and replace in the database:
            
            TABLE                                COLUMN
            -----                                ----
            modx_context                         key
            modx_access_context                  target
            modx_access_media_source             target
            modx_access_category                 context_key
            modx_access_elements                 context_key
            modx_access_resources                context_key
            modx_access_resource_groups          context_key
            modx_access_templatevars             context_key
            modx_context_setting                 context_key
            modx_media_sources_contexts          context_key
            modx_media_sources_elements          context_key
            modx_context_resource                context_key
            modx_site_content                    context_key
            


            Have I missed anything?
              • 34027
              • 30 Posts
              In other words:

              UPDATE modx_context                 SET `key`         = 'new context name' WHERE `key`         = 'old context name';
              UPDATE modx_access_context          SET `target`      = 'new context name' WHERE `target`      = 'old context name';
              UPDATE modx_access_media_source     SET `target`      = 'new context name' WHERE `target`      = 'old context name';
              UPDATE modx_access_category         SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_access_elements         SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_access_resources        SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_access_resource_groups  SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_access_templatevars     SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_context_setting         SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_media_sources_contexts  SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_media_sources_elements  SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_context_resource        SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              UPDATE modx_site_content            SET `context_key` = 'new context name' WHERE `context_key` = 'old context name';
              
              
              • Adding a name field for display purposes has already been added as a feature request, has already been submitted as a Pull Request, and will be integrated for the MODX 2.3.x releases.
                • Quote from: opengeek at Sep 20, 2012, 01:34 PM
                  ... will be integrated for the MODX 2.3.x releases.
                  Kewl! That would be really awesome! Since I tend to organize my multidomain websites with context-name == subdomain-name I would finally get a chance to also rename "web" into "www" or whatever? THAT would be killer!

                  Looking forward to 2.3
                  Oliver
                    MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
                    http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
                    • 40249
                    • 31 Posts
                    what happend to the feature to rename the default context? we are already on 2.3.3 and i couldn't find the option.
                      • 3749
                      • 24,544 Posts
                      Right-click on the context in the tree and select "Edit Context". You can the display name for the tree. [ed. note: BobRay last edited this post 8 years, 6 months ago.]
                        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