1

Is there a way to use Resources Router to only route for entries in one particular channel, then for everything else, use the normal EE template structure?

I've tried:

':any'  => function($router, $wildcard_furniture) {
           if ($wildcard_furniture->isValidEntry(array('channel' => 'furniture'))) {
           $router->setTemplate('product-category/index');
         } else {
      $router->stopRouting();
    }
       }

1 Answer 1

1

This should work:

$config['resource_router'] = array(

    ':any' => function($router, $wildcard) {
        if ($wildcard->isValidUrlTitle( array('channel' => 'furniture') )) {
            $router->setTemplate('product-category/index');
        }
    },

};

If there's no match then no template would be set and ee carries on.

I would think it's faster if you can narrow the url possibility down because then that db call will only happen on matched pages (i.e.: domain.com/furniture/chair):

    'furniture/:any' => function($router, $wildcard) {
        if ($wildcard->isValidUrlTitle ... etc....
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.