On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • EDITED

    Hi guys, I make this as an official hack from me to MODx. Waiting for the core team to decide whether it’s going to be implemented for the future release or not.

    This hack will allow multiple domains to be hosted on one MODx installation base. Manager able to setup the desired strart doc id and error doc id for each subsites under System Settings configuration page. This mostly affect friendly alias path that is being turned on.

    Now it provides root folder for the subsites to be located anywhere, without the needs to located them right on the first level or root level. The alias itself can be anything as well, doesn’t have to be the domain/subdomain name.

    It has been tested for several minutes by me. If somebody willing to test this further, it will be great.
    PS: Modification doesn’t affect any usability of using other resources created for MODx, due to the fact this hack changes all the needed API to keep everything act as if there is no modification at all.

    Here is a little scrrenshot for the system setting page
      Wendy Novianto
      [font=Verdana]PT DJAMOER Technology Media
      [font=Verdana]Xituz Media
    • The actual MODx parser is in /manager/includes/document.parser.class.inc.php.

      Hope that helps!
        [html]<div><div style="float:left;"><a href="http://modxcms.com/Ditto-487.html" target="_blank"><img src="http://modxcms.com/assets/images/ditto.gif" alt="" border="0"></a></div><div style="float:left; padding: 0 5px 0 5px; border-left: 2px solid #ddd; margin-left: 5px;"><a style="display:block;"href="http://modxcms.com/ditto_docs.html">Documentation</a><a style="display:block;" href="http://modxcms.com/ditto_trac.html">TRAC (Bugtracker)</a><a style="display:block;"href="http://modxcms.com/forums/index.php/board,180.0.html">Forum</a><a style="display:block;"href="http://modxcms.com/forums/index.php/topic,13348.0.html">How to get help</a></div><div style="float:left; padding: 0 5px 0 5px; border-left: 2px solid #ddd;"><a style="display:block;"href="http://modxcms.com/ditto_wiki.html">User Wiki</a><a style="display:block;" href="http://modxcms.com/ditto_credits.html">Credits</a><a style="display:block;"href="http://modxcms.com/ditto_svn.html">SVN Server</a><a style="display:block;"href="http://modxcms.com/ditto">Ditto HQ</a></div><div style="float:left; padding: 0 5px 0 5px; border-left: 2px solid #ddd;"><a style="display:block;"href="http://modxcms.com/ditto_stable_download.html"><strong><span style="color:#CC0000;">Stable Download</span></strong></a><a style="display:block;"href="http://modxcms.com/ditto_download.html"><strong><span style="color:#CC0000;">Development Download</span></strong></a></div><div style="clear: both;"></div></div>[/html]
      • Maybe you need something like an OnMakeUrl event so you can modify all your MODx generated urls from a plugin without having to hack the core, correct?
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
        • Yeap, actually I still need to hack the core though, I change the makeFriendlyURL() and makeURL() function to make sure that every friendly alias path need to be outputed, it will remove all the leading alias virtual directory, which based on the name of the domain being used.

          For example, "subdomain.domain.com/home.html". The "subdomain.domain.com" is the first folder level that is going to contain all the documents specific to that subdomain. So in this case, both of the methods, instead of outputing that, it will remove the "subdomain.domain.com", and return "home.html".

          Now the last bit that I need to change is executeParser() function, which is before the event onWebPageInit, I hack into the function and change $alias variable to be appended with "subdomain.domain.com", before the $alias variable being processed and returning the exact document.

          All the changes will only happen, when the alias path option being enabled in the manager setting. I also plan to have a new configuration setting, to enabled this mode, which allow subsite or not, if it is, then all the changes in that 3 functions will run, if not, it will proceed as standard MODx system.

          Do you think this is do able? Did I cover all the basic ground for subsite? I did the changes of the executeParser() function and it works.

          Please let me know if I do wrong, and I really appreciate all the helps, because I’m not a good PHP programmer, so any help from the core coder will be awesome.

          Thanks
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
          • I think it’s workable but you just have to give it a try.
              xWisdom
              www.xwisdomhtml.com
              The fear of the Lord is the beginning of wisdom:
              MODx Co-Founder - Create and do more with less.
            • My last question, hopefully.

              Is there anyway to search document id based on their alias, other than going back and forth of the database? Is there any function available to do that? I haven’t check the API function yet, but if somebody could direct me, it will be great.

              How do I add a new option under manager setting inside the core code to have subsite disable or enable option?

              Jason, if you can give me a hint, it will be really2 awesome.

              Thanks
                Wendy Novianto
                [font=Verdana]PT DJAMOER Technology Media
                [font=Verdana]Xituz Media
              • I found this wonderfull array inside the core
                $modx->documentListing


                Can we use that for snippet as well? It has all the pages alias with the corresponsding pageid attached to it.

                It’s awesome.
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                • Thanks jason for the help, I have the subsites working just fine now, without having to use .htaccess.

                  I did a lot of hacking inside the document.parser.inc.php, but it’s mostly just adding a few lines of code to modify certain behaviour in producing friendly alias path, while on subsites mode. It also change the site start and error page to the parent folder for subsites.

                  All I need is to modfy the manager setting to have this option available for user to check or uncheck.

                  Btw, is there any thought of implementing madmage multi lingual solution? I think it will be a good start for modx to have multi lingual solution.

                  PS: Sorry if this post containing a bunch of topics, which are unrelated to the topic itself. Don’t ban me for this moderator. tongue

                  Regards,
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media
                  • Wendy, we’ll be seriously evaluating when and what method for front-end multi-lingual sites very soon. smiley
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • Quote from: rthrash at Jan 05, 2006, 10:00 PM

                      Wendy, we’ll be seriously evaluating when and what method for front-end multi-lingual sites very soon. smiley

                      That’s a good thing to know. Please update me when the time come. I’m looking forward for the future of MODx, by looking at the current progress right now, I can see the multi lingual content being implemented in the near future.

                      Btw, I’m done with subsites hacking, I added 2 options in manager system configuration setting to allow subsites or not, and it’s going to depend on their domain. I believe this subsites solution is only affecting user who want to use alias path.

                      If it is going to be implemented to the core, I wouldn’t mind sharing what I did with the code.
                      Hoping this could be on official option on MODx in the next release, including the multi lingual from madmage or whatever that you guys come up with.

                      Thanks for nurturing this system.
                        Wendy Novianto
                        [font=Verdana]PT DJAMOER Technology Media
                        [font=Verdana]Xituz Media