Resource Router and MSM
Opened this issue · 5 comments
Deleted user commented
Does Resource Router work with MSM, and could you provide some examples/suggestions of how to use it with MSM?
Thanks
Deleted user commented
Any answers on this? We are attempting to use it with EE3 and need to find out if it will work for us.
rsanchez commented
There's no specific integration with MSM, but I think it should be possible.
You can check for site ID in your route callbacks:
$config['resource_router'] = array(
'blog/:url_title' => function ($router, $wildcard) {
$site_id = ee()->config->item('site_id');
// this route is only meant for the main site
if ($site_id != 1) {
return $router->set404();
}
return $router->setTemplate('blog/_detail');
},
);
roberthallatt commented
You can also use a case statement that does a check on the domain name allowing you to prevent the code from being executed by another site in your MSM install.
Deleted user commented
@roberthallatt could you provide an example of how to do this?
roberthallatt commented
@ashleymarchant It would look something like this:
switch ($_SERVER['SERVER_NAME']){
case "www.yoursite.com":
$config['resource_router'] = array(
your routes..
);
break;
}