I’m trying out the Contexts to use one modx installation to manage multiple sites. I’ve tried a couple of different ways to switch contexts, but I’m finding that the resource tags are not being parsed in non-web contexts.
Here’s my setup:
- Installed modx 2.0.0-alpha-5 on (for example) www.site1.com - manager = www.site1.com/manager.
- Set up www.site2.com to point to the same MODx install directory
Context 1 (default: web)
- Created a basic template which outputs the site name, page title in the TITLE tag, and the page’s content in the BODY.
- Created a resource (page ID 1) which uses the above template
- Preview the page - works fine
Context 2 (new context: site2)
- Created a new context called site2
- Created a resource (page ID 2) which also uses the above template in the site2 context
- Added the site_name and site_start (page ID 2) settings to context 2
- Changed index.php to switch the context as follows:
switch ($_SERVER['HTTP_HOST'])
{
case 'www.site2.com':
$modx->initialize('site2');
break;
default:
$modx->initialize('web');
break;
}
Whenever I visit www.site2.com/?id=2 - modx parses the correct site name tag from the context, but doesn’t parse the document content tags - they don’t come out in the HTML output but don’t have any values in them (blank.)
As this was an early recommendation by Jason for alpha-1, I had another look on the forums and came up with this:
http://modxcms.com/forums/index.php/topic,29455.msg179824.html#msg179824
So I tried this also:
- Created a plugin called "Context Switcher" assigned to the OnHandleRequest event with the text in this article
- Restored the changes made to index.php so the web context loads by default
- Added the http_host (www.site2.com) and site_url (
http://www.site2.com{base_url}) settings to the context
It still makes no difference - no resource tags are being parsed in the site2 context (web context still works fine.)
It’s switching the context OK because the site name changes, but it won’t parse the document tags in the non-web contexts. I’ve got a feeling it’s something ridiculously easy I’ve missed but I cannot see what!
Any help would be appreciated.
Thanks,
Andy