rsanchez / resource_router

Resource Router for ExpressionEngine
MIT License
48 stars 12 forks source link

Resource Router and MSM #36

Open ghost opened 8 years ago

ghost commented 8 years ago

Does Resource Router work with MSM, and could you provide some examples/suggestions of how to use it with MSM?

Thanks

ghost commented 8 years ago

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 8 years ago

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 7 years ago

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.

ghost commented 7 years ago

@roberthallatt could you provide an example of how to do this?

roberthallatt commented 7 years ago

@ashleymarchant It would look something like this:

switch ($_SERVER['SERVER_NAME']){

     case "www.yoursite.com":

            $config['resource_router'] = array(
                your routes..
            );

     break;

}