We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9172
    • 32 Posts
    Hello! At first, sorry for my english, is not my native language.

    I want to use one MODX’s user accounts for few sites, placed on the same server.

    There is present ready solution or mod, or i need make it myself? smiley

    thanks for answers!
      Uwaga! Wlaczamy faze!
      • 33337
      • 3,975 Posts
      Nope, its not available at the moment. But we look forward you see your solution wink.

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

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 25663 MODX Staff
        • 12,272 Posts
        This is however on the roadmap and will be a feature in the future. smiley
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 33372
          • 1,611 Posts
          Actually, I can imagine a way to make this work using the current 0.95 code. What if you set up your sites in MODx container/folders and used a combination of friendly alias paths and .htaccess to redirect the traffic? You could also write a simple plugin to forward requests and rewrite URLs based on the domain name and/or ultimate parent id. You could set your site start page to an index of all of your sites or a particular one of them. And you could use the current manager user system to control access to specific sites for different admins. You’d also have to make sure that your error page worked for all of these sites and limit your search scripts, etc. to the proper subfolders.

          There are probably some other minor details that would need to get worked out in the process (like making sure that the RTE works for all sites and your .htaccess code doesn’t affect image paths, etc.), but is there any reason that folks can think of why this wouldn’t work?

          Many commercial web hosts have explicit policies in their terms of service prohibiting you from doing this, so check yours before you do a lot of work just to have your host shut you down.
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 9172
            • 32 Posts
            I still not dig the code deep enough, but quick look give me at least one idea.

            Look, i can install two MODx using one DB, where only table prefixes is different.

            Later, i change table names in secondary MODx code, for example:

            $sql = "SELECT setting_name, setting_value FROM $dbase." . $table_prefix . "user_settings WHERE user=" . $user_id;

            i must change to

            $sql = "SELECT setting_name, setting_value FROM $dbase."modx1.user_settings WHERE user=" . $user_id;


            Now i’m too lazy, but after some sleep i’ll try it.
              Uwaga! Wlaczamy faze!
              • 33372
              • 1,611 Posts
              If all you want to do is to install more than one copy of MODx in the same database, just create multiple MODx folders and use different table prefixes in each installer.
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 9172
                • 32 Posts


                No! I need two MODx with different content, but with same users - at least, managers.

                Unfortunately, nice function

                   function getFullTableName($tbl) {
                        return $this->dbConfig['dbase'] . "." . $this->dbConfig['table_prefix'] . $tbl;
                }


                used not so widely. Because it’s to easy extend this function to:

                   function getFullTableName($tbl) {
                       $table_prefix = $this->dbConfig['table_prefix'] ;
                   
                       if ($tbl=="manager_users") { $table_prefix = "modx1_"; }
                     .......
                       if ($tbl=="user_attributes") { $table_prefix = "modx1_"; }
                
                        return $this->dbConfig['dbase'] . ".$table_prefix". $tbl;
                }



                Hey, Developers! It’s an Order! smiley
                  Uwaga! Wlaczamy faze!
                  • 33372
                  • 1,611 Posts
                  I’m not sure why you’d need to make separate database tables to do that. Can’t you just do something along the lines of what I suggested first? You can restrict your manager users to specific document groups, so Group X would not be able to edit the documents that belong to Group Y.
                    "Things are not what they appear to be; nor are they otherwise." - Buddha

                    "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                    Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                    • 9172
                    • 32 Posts
                    I want two (and more!) modx, not one smiley
                      Uwaga! Wlaczamy faze!
                      • 33372
                      • 1,611 Posts
                      Let me see if I understand what you’re looking for...

                      You want to manage several sites via one MODx manager
                      You want all of the data to be in one database
                      You want to share the manager and its users among all sites

                      So either you do something like I suggested in the beginning (which would get you all of this with the exception of separate configuration options for each "site"), or you hack the manager users table to add the site that user can access, do multiple installs with table prefixes equal to each site name (e.g., site1_modx_), and if you find that adding that to the getFullTableName function doesn’t do the trick create a plugin that sets $this->dbConfig[’table_prefix’] equal to the user’s site name value.

                      The latter is a lot more difficult...
                        "Things are not what they appear to be; nor are they otherwise." - Buddha

                        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options