I have followed XXXX instruction on how to setup a multi site context
http://www.h-quadrat.com/techblog/111-modx-revolution-multi-domain-context-installation-english.php
To make it work. I had to add some code to index.php
//$modx->initialize('web');
/* setup for multiple domains */
switch(strtolower(MODX_HTTP_HOST)) {
case 'www.modx-templates.com:80':
case 'www.modx-templates.com':
// if the http_host is modx-templates.com, switch the context to web
$modx->initialize('web');
break;
case 'www.ffmwireless.de:80':
case 'www.ffmwireless.de':
// if the http_host is ffmwireless.de, switch the context to ffmwireless
$modx->initialize('ffmwireless');
break;
case 'www.thesearchgoeson.com:80':
case 'www.thesearchgoeson.com':
// if the http_host is thesearchgoeson.com, switch the context to thesearch
$modx->initialize('thesearch');
break;
default:
// by default / if no other rule can be applied, load 'web' context
$modx->initialize('web');
break;
}
This works very nice, but I’m wondering if there isn’t a more straightforword method to to this.
As context names I have used Domain URLs:
www.thesearchgoeson.com
www.ffmwireless.de
All I need to know are the available Contexts. Then I get rid of ’mgr’ and ’web’ and voila I have a list of all available domains
As far as I understand there is a list of all contexts in the database: modx_context -> ’id’.
OK, I can make a simple db query, but from what I have learned from the API it should be dead simple to get an array with all available contexts by utilizing xPDO.
Questions:
- I’m a total xPDO noob. Can you give me any advice how to do that?
- Do you see any performance problems with this approach?
- Do you have other ideas how to do this automacically without touching index.php everytime I add a new context?
- Is there a way to do this without touching index.php?
I really would appreciate any input.
Kind regards,
pepebe