We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47400
    • 21 Posts
    Ok so I've worked on a couple of sites with ModX now and in general I'm loving it's flexibility and what I can build with it compared to other CMS's I've tried in the past. I have run into a couple of problems, probably caused by myself and the workflow that I've used with other CMS's not being the best with ModX so I'm interested in other people's workflows and how you tackle things.

    Specifically, how do you handle a client who has an existing website that you are replacing?

    To put that into context, one of the projects I worked on recently was for a client with an existing site on their own server. We were building their new site on our server using a domain reference - so an IP followed by their domain name - which worked fine to start with but I couldn't get friendly URLs to work until we put their site live by pointing the domain at our server. Also, the manager only works properly by visiting the domain referenced URL so clicking "View Site" or "Preview Page" doesn't work properly anymore either. It's also caused me some problems with Wayfinder not being able to resolve the link to the home page (which I've managed to fix with some jQuery and output modifiers).

    So I now know not to use a domain reference with ModX, but I'm wonder what the best workflow is when dealing with a client that has an existing site. Do you take their site down and put a holding page up on your server while developing the new site behind the scenes? Is it possible to develop on another URL or sub-domain of our website (e.g. dev.mysite.com) and then move it to their domain afterwards? I think I saw some documentation about that somewhere?

    Any other workflow tips are welcome, I want to get much better with ModX development!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes, it is easy enough to set up MODX in a subdirectory. You just need to edit the .htaccess file in the MODX subdirectory to reflect its path with the RewriteBase directive.

      Then when you are finished, you can just move the MODX files into place, and run Setup again in upgrade mode and/or edit the four config files to reflect the new path. Or you can adjust your web server's configuration to point the main domain to the subdirectory.

      Usually I move the files into place, first renaming all original files with .old at the end to disable them. That way if something goes wrong, you can just rename the MODX index.php file to index.php.new, and rename the old files to remove the .old suffix.
        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
        • 24414
        • 45 Posts
        I keep all my installs in subdirectories and keep at least 1 previous install in case of issues, I develop on subdomains named after date of install and MODX version, root is something like:

        .htaccess
        140903231/
        client files from site to be redeveloped
        


        I develop on say, 140903231.example.com, then when the time comes to make live I flush cache, edit domain info in /core/config/config.inc, point to the install location in [root] .htaccess.

        RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
        RewriteRule (.*) /140903231/$1 [L,NC]
        


        You could also edit httpd.conf if you have access, work in cPanel or other webspace manager.

        Then delete 140903231.example.com subdomain and you are good to go. If you need to go back to an old version you can quite easily. I see a lot of people seem to do install in place with new versions of MODX but I would rather be cautious and have a previous version that I can jump to by editing a few characters should anything go wrong.

        A typical root folder for me is something like:

        .htaccess
        140903231/
        1404052214/
        


        I also use this format for databases, system boilerplates, amongst other things. Probably slower than other methods always working on copies of everything but feels safer to me. Can automate things with shell or PHP scripts to speed things up a bit. [ed. note: ram last edited this post 12 years ago.]
          • 3749
          • 24,544 Posts
          Specifically, how do you handle a client who has an existing website that you are replacing?

          I just did this last night for an Evo to Revo conversion.

          This worked really well and I didn't even have to create a virtual host, although in my case, the client's original site was in a subdirectory I'll call clientSite, reachable at clientSite.com:

          Installing

          1. Create a subdirectory called clientSite2 - it should be accessible with yourdomain.com/clientSite2.
          2. Copy the MODX files to the clientSite2 directory, or use one of the installer scripts mentioned on the forums there.
          3. Put this in the browser's address bar: http://yourdomain.com/clientSite2/setup. (you may need to create the database first)
          4. If Setup goes well, let it delete the Setup directory
          5. Once MODX is installed, you should be able to log in by going to http://yourdomain.com/clientSite2/manager/

          Building the site

          This part is all done the normal way. All your templates need this tag in the head section:

          <base href="[[++site_url]]" />


          If, for some reason, that doesn't work (internal links fail), use this one:

          <base href="http://yourdomain.com/clientSite2/" />


          All internal links on the site should be in the form of link tags:

          <a href="[[~12]]">Some Text</a>


          The number in the link tag is the Resource ID of the resource it points to (visible in parentheses next to the page title in the Resource Tree at the left side of the Manager).

          Putting it in place

          When the site is ready to replace the original, this is all you need to do:


          1. (optional) If you customized the base href tag, change the href to "[[++site_url]]" or "clientSite.com".
          2. Log out of the dev. site
          3. In cPanel's file manager, edit the following four files. Change all instances of yourdomain.com/clientSite2/. to just clientSite.com (the address of the original site) -- be sure you get them all in config.inc.php:

            • config.core.php (MODX root)
            • manager/config.core.php
            • connectors/config.core.php
            • core/config/config.inc.php

          4. Rename the clientSite directory to clientSite.old (site goes down at this point)
          5. Rename the clientSite2 directory to clientSite (site comes back up as the new site)
          6. Important: delete all files in the clientSite/core/cache directory
          7. If you customized the base href tag in the template(s) and haven't fixed it yet, you'll need to change it now or internal links will not work.

          At this point, the newly developed site should be working fine at original address. If not, check the paths in the four config files you modified.

          You can delete the old site (in the clientSite.old directory) now, but I like to leave it there a while to make sure everything is OK with the new site. I modify the index.php files in the root and Manager folders by adding this at the top just below the starting php tag:

          die('Unauthorized');


          Don't forget to remove that line if you end up having to restore the old site.



          [ed. note: BobRay last edited this post 12 years 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