Context in Modx Revolution provides us with the ability to maintain separate configuration files which we can use to run a language-specific version of our website, for example, or locate our core files outside of the site's root folder for enhanced security.

In this section, we will use Context to create a different website called AnotherRevo from the Modx Revolution installation base that we are using for MyRevo. This new site can be treated as a sub-domain or a main domain. We will also apply appropriate security settings to the registered users and editors of the new site. As usual we will approach this in steps.

  1. Clear Site Cache - Site-->Cache and logout of Manager.
  2. Update Apache's VirtualHost:
    Using Windows Explorer or any text editor, we open httpd-vhosts.conf under c:\wamp\bin\apache\Apache2.2.17\conf\extra and add the lines below to the bottom of the file:
      <VirtualHost *:80>
          ServerAdmin webmaster@localhost
          DocumentRoot "c:/wamp/www"
          ServerName localhost
          ErrorLog "logs/localhost-error.log"
          CustomLog "logs/localhost-access.log" common
      <VirtualHost *:80>
          DocumentRoot "c:/wamp/www/myrevo/anotherrevo"
          ServerName anotherrevo
          <directory "c:/wamp/www/myrevo/anotherrevo">
              Options Indexes FollowSymLinks
              AllowOverride all
              Order Deny,Allow
              Deny from all
              Allow from
    • Uncomment: In httpd.conf under C:\wamp\bin\apache\Apache2.2.17\conf, remove the # sign around line 467 in the file Include conf/extra/httpd-vhosts.conf.
    • Add Extra Line: In hosts under c:\windows\system32\drivers\etc, add at the very end of the file: anotherrevo
    • Restart Apache
  3. Create Folders/Files:
    • create: c:\wamp\www\myrevo\anotherrevo
    • create: c:\wamp\www\myrevo\anotherrevo\assets
    • create: c:\wamp\www\myrevo\anotherrevo\assets\templates
    • copy: .htaccess, index.php and config.core.php from C:\wamp\www\myrevo to c:\wamp\www\myrevo\anotherrevo
    • copy: everything from c:\wamp\www\myrevo\assets\templates\ to c:\wamp\www\myrevo\anotherrevo\assets\templates\
  4. Edit Index File
    • In: c:\wamp\www\myrevo\anotherrevo\.htaccess change:
      RewriteBase /myrevo to RewriteBase /myrevo/anotherrevo
    • In: c:\wamp\www\myrevo\anotherrevo\index.php amend:
      $modx->initialize('web'); to $modx->initialize('anotherrevo');.
    • In: c:\wamp\www\myrevo\anotherrevo\config.core.php change:
      define('MODX_CORE_PATH', dirname(__FILE__) . '/core/'); to
      define('MODX_CORE_PATH', 'C:/wamp/www/myrevo/core/');
  5. Delete everything under C:\wamp\www\myrevo\core\cache - not necessary but cache can be a problem sometimes.
  6. Create New Context
    • We create Contexts in two ways: either by replicating existing context or going through System-->Contexts. When defining a Context, we need to provide resource IDs for certain pages such as the error page, as we did in Modx Revolution Development - Part 03 - Basic Systems Settings. Since we already have these pages, and also the existing website does not have that many resources, we will use the former method and duplicate MyRevo to create our new context. Therefore, we right-click on web under Resources and choose Duplicate Context and give a New Key of anotherrevo. We should now see AnotherRevo context together with new IDs for the duplicated but unpublished pages added to the Resource tree.
  7. Duplicate Base Template for AnotherRevo:
    • Right-click Base Template-->Duplicate Template and provide the name of Another Base Template
    • We could duplicate other templates and chunks but they are not immediately relevant.
  8. Configure AnotherRevo Context:
    We go back to the Resources tab so that we can see the pages and their IDs on the tree.
    Following System-->Contexts, right-click on AnotherRevo-->Update Context, then Context Settings tab --> Create New and update as follows, leaving other features at default, except indicated:
    Key Name Value
    base_url BaseURL /
    default_template Default Template (note Field Type:Template)
    error_page Error Page 31
    http_host HTTP Host anotherrevo
    site_name Site Name Another Revo
    site_start Site Start 30
    site_unavailable_page Site Unavailable Page 32
    site_url Site URL http://localhost/myrevo/anotherrevo/
    unauthorized_page Unauthorized Page 33

    We will not do anything with the Context Access Permissions tab because the relevant settings will be populated for us after we had gone through Security settings, as we did in Modx Revolution Development - Part 09 - Security.
  9. Clear Site Cache - Site-->Cache.
  10. Update AnotherRevo Home page to use AnotherRevo Base Template and also amend the title to Another Revo Home so that we can see the effect, then preview resource.
  11. Create/Edit/Delete other resources, templates, chunks and css as necessary. Some of the necessary changes include IDs for membership, simplesearch landing page which would now be ID 48 and chunks for personalization and sidebars. Also, for Sitemap links to work properly, we open Snippets-->sitemapFriend; on its Properties tab we click once on Default Properties Locked to unlock it and then change the value of urlScheme from abs to Full, then SAVE.

Security Settings

The steps for implementing membership and managing editors and other users are similar to those covered in Modx Revolution Development - Part 08 - Membership and Modx Revolution Development - Part 09 - Security, except that any reference to web now becomes the new context of anotherrevo.

Comments (0)

Add a new comment:

This thread has been closed from taking new comments.