We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17665
    • 54 Posts
    Djamoer mentioned you’re having problems getting the subsites hack to work. Is there any way I can help? We’ve been using it quite a bit on our site and it does exactly what we need:

    www.everynation.org
    campus.everynation.org
    websites.everynation.org
    everynationpv.org
    vcm.com
    ...

    These are all in the same modx install.
    They key for us was to use the "root" of modx almost as a "httpdocs" folder on a web host. Eeach folder in the root represents a domain and (*important*) it has an alias set that matches that domain. This was something that I didn’t completely understand at first. Basically, to get to campus.everynation.org you are actually going to an alias named "campus.everynation.org" (thus http://campus.everynation.org/campus.everynation.org/) and Djamoer’s wonderful code strips it out to just http://campus.everynation.org/.

    Let me know if there is any way I can help.
      • 32241
      • 1,495 Posts
      Hi luke,
      I see that you’re still using the old hack that I built.
      Would you mind trying out my latest hack, it’s being attached on the first post. Basically what it does is providing a controlable start id, and error id. In this 1.0 release, I forgot to include option to change unauthorize page id, which usually available on the modx system config. Try checking it out, let me know hwther it’s having problem or not on your site. I did quite a few modification, so it might break banzai’s server. If you have time to test the code out, please inform me back if there is something wrong in it.

      Btw, if you can get this to work, it will better suited for your production site, because you can clearly defined the error page id, start page id, and unauthorize page id (added in the next release 1.1).

      Thanks for your willingness to help Luke wink
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 17665
        • 54 Posts
        Sounds good! I’ll play around with it tomorrow. I actually just used the unauthorized page setting today for the first time as I just setup a secure section of our website.

        I put together a full development installation at a different domain so I can test it out there. We’re getting too many hits now on this site to mess with it (yes, that’s right, your "hack" on a live site!).

        For us, this was a make or break addition to MODx so I would be glad to spend some time to help you improve this great feature.

        (am I laying it on too thick? I’m hoping the core developers will hear my enthusiasm as they read this and feel encouraged to implement this in the next release... one can only hope)

        ;)
          • 32241
          • 1,495 Posts
          I can hear your enthusiasm as well wink We will work together to make sure that this is stable enough to get into the core smiley
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 25663 MODX Staff
            • 12,272 Posts
            Just for ease of forum search: sub-sites sub sites
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 17665
              • 54 Posts
              I didn’t get a chance to mess with this yesterday, but I loaded it up today and I’m just getting this error:

              « `` is not numeric and may not be passed to makeUrl() »

              Not exactly sure if I’m doing it right. Do I still need to name the alias the same as the domain and have that be a folder in the root?

              I’m trying to use pv.wineverynation.org as an example... I put it in the "Site Main Domain" (which is now just a list of domains OTHER than the site main domain, right?) of pv.wineverynation.org 832 832 and document 832 has an alias named pv.wineverynation.org. Is that all correct?

              I haven’t yet looked at the modifications of the document parser to see what’s going on, but I just wanted to make sure I’m using this correctly.
                • 32241
                • 1,495 Posts
                I think I might figure out what causing the problem.
                I believe most of you guys here know PHP scripting language much better than me. So here is the problem
                <?php
                		$domainsTemp = split("\n", trim($this->config['subsites_domain']));
                		$this->config['subdomains'] = array();
                		if(is_array($domainsTemp)) {
                			foreach($domainsTemp as $key=>$rawdomain) {
                				$tempConfig = split(" ", $rawdomain);
                				if(is_array($tempConfig) && count($tempConfig) == 4 && is_numeric($tempConfig[1]) && is_numeric($tempConfig[2]) && is_numeric($tempConfig[3])) {
                					$domain = strtolower($tempConfig[0]);
                					$this->config['subdomains'][$domain]['startid'] = $tempConfig[1];
                					$this->config['subdomains'][$domain]['errorid'] = $tempConfig[2];
                					$this->config['subdomains'][$domain]['unauthorized'] = $tempConfig[3];
                					$rootAlias = trim($this->makeUrl((int) $this->config['subdomains'][$domain]['startid'], '', ''), '/');
                					$rootAliases = split('/', $rootAlias);
                					$rootAlias = '';
                					for($i = 0; $i < count($rootAliases); $i++) {
                						if($i < count($rootAliases) - 1) $rootAlias .= $rootAliases[$i].'/';
                						else {
                							$rootAlias .= substr(substr($rootAliases[$i], 0, strlen($rootAliases[$i]) - strlen($this->config['friendly_url_suffix'])), strlen($this->config['friendly_url_prefix']));
                						}
                					}
                					$this->config['subdomains'][$domain]['startalias'] = $rootAlias;
                				}
                			}
                		}
                ?>
                


                Notice that I need a way to separate line return. On the first line, I’m using "\n" as the separator to split the input from the database. Basically the database has the value of whatever the user input into the setting.
                So I’m assuming that the problem is being caused by the difference between each O/S. I believe some of O/S using "\r\n", while others using "\n". If that’s the case, can somebody help me find a better way to split out text based on line return?
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                  • 32241
                  • 1,495 Posts
                  Try this one out, and report to me if there is any bug
                  http://svn.djamoer.net/?do=browse&project=MODx&path=/trunk/hacks/subsites/

                  That’s the latest fix, includes unauthorize page as well.
                  So you need to add another page id as the error page for unauthorize access.

                  EDIT: If you guys have problem with it, please do me a favor.
                  Create a new snippet, name it TestServerVars. Inser this code:
                  echo '<pre>';
                  print_r($_SERVER);
                  echo '</pre>';
                  

                  Then add the snippet [!TestServerVars!] on any page that you can access. Please paste the output to this thread, for me to further investigate the problem.

                  Thanks
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media
                    • 32241
                    • 1,495 Posts
                    Btw, I did a quick redirection test using sendredirect, and so far I haven’t found any problem yet.
                    I’ll test this further against this hack.
                      Wendy Novianto
                      [font=Verdana]PT DJAMOER Technology Media
                      [font=Verdana]Xituz Media
                      • 2762
                      • 1,198 Posts
                      Wendy, I’ve tried to download your latest document.parser.class.inc.php but winrar can’t open it (corrupted file) :’(
                        Free MODx Graphic resources and Templates www.tattoocms.it
                        -----------------------------------------------------

                        MODx IT  www.modx.it
                        -----------------------------------------------------

                        bubuna.com - Web & Multimedia Design