0

I'm using the following (https://github.com/rsanchez/resource_router):

$config['resource_router'] = [
    'news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources' => 'www/news-and-resources',
    'cn/news-and-resources' => 'www/news-and-resources',
    'zh/news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources/:pagination' => 'www/news-and-resources',
];

The last array item should match a url of -

http://www.example.com/usa/news-and-resources/P3

But it just throws a 404 error, even though I know it should load more entries.

What's causing this problem? I'm using Expression Engine 3.4.1

Update:

Using the Resource Router plugin (purely because I can’t get this working inside EE’s routing system) I’ve done this:

$config['resource_router'] = array(
    'news-and-resources/:pagination' => 'www/news-and-resources',
    '(usa|cn|zh)/news-and-resources/:pagination' => 'www/news-and-resources',
    'news-and-resources/(news|resource)/:pagination' => 'www/news-and-resources',
    '(usa|cn|zh)/news-and-resources/(news|resource)/:pagination' => 'www/news-and-resources',
);

So, based on the routes above, the following page requests work and load correct content:

http://www.example.co.uk/news-and-resources
http://www.example.co.uk/news-and-resources/P3
http://www.example.co.uk/news-and-resources/news
http://www.example.co.uk/news-and-resources/resource
http://www.example.co.uk/news-and-resources/news/P3
http://www.example.co.uk/news-and-resources/resource/P3

http://www.example.co.uk/usa/news-and-resources
http://www.example.co.uk/usa/news-and-resources/news
http://www.example.co.uk/usa/news-and-resources/resource
http://www.example.co.uk/usa/news-and-resources/news/P3
http://www.example.co.uk/usa/news-and-resources/resource/P3

You’ll notice the only difference is that there is no

http://www.example.co.uk/usa/news-and-resources/P3

And that’s because it’s the only one that doesn’t work, despite there being a route defined

'(usa|cn|zh)/news-and-resources/:pagination' => 'www/news-and-resources

3
  • 1
    EECMS 4? Already? You're fast!
    – Sobral
    Sep 28 '16 at 18:39
  • Also, your first segment could be (usa|cn|zn).
    – Sobral
    Sep 28 '16 at 18:40
  • Haha, 3.4.1, my bad ;) Sep 28 '16 at 18:42
0

Do the other links work as expected (like zh/news-and-resources)? Try this:

$config['resource_router'] = array(
    'news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources/:pagination' => 'www/news-and-resources',
    'cn/news-and-resources' => 'www/news-and-resources',
    'zh/news-and-resources' => 'www/news-and-resources',
);

You should only need the usa/news... once, because :pagination is an optional segment: it should match that line with or without pagination.

Update: From Robson's comment, this is also possible:

$config['resource_router'] = array(
    'news-and-resources' => 'www/news-and-resources',
    '(usa|cn|zn)/news-and-resources/:pagination' => 'www/news-and-resources',
);

To test that resource router is matching the url, you can do something like:

$config['resource_router'] = array(
    'usa/news-and-resources/:pagination' => function($router, $wildcard) {
        return 'This URL matched.';
    }
);
5
  • Yeah the other routes work fine, I'll try your idea - 5 mins Sep 28 '16 at 18:36
  • Nope, still throws a 404, I'm totally stumped Sep 28 '16 at 18:42
  • You don't have anything set in the regular ee template router that would conflict? Just guessing. Sep 28 '16 at 18:45
  • Not that I'm aware of, though interestingly if I change 'usa/news-and-resources/:pagination' => 'www/news-and-resources', to 'usa/news-and-resources/:pagination' => 'www/index', it does re-route to the index page. So, seems like there's a bug in my pagination pulling in results rather than routing Sep 28 '16 at 18:47
  • Okay, so the route matches, but the pagination is broken. I guess it's time for me to speak to Ellis Labs, unless you guys are aware of anything? Sep 29 '16 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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