rsanchez / resource_router

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

set404 loading blank page #23

Open jhenriksen opened 9 years ago

jhenriksen commented 9 years ago

I'm having an issue trying to call set404. It's just loading a blank page rather than the 404 page set in the global template preferences. Any ideas? Here's what I'm working with:

$config['resource_router'] = array(
    //Redirect old lab URLs to new lab templates
    'research/labs/:any/:all' => function($router, $wildcard_1, $wildcard_2) {
        $lab_channel_ids = array(
            //'old_lab_url_slug' => channel_id
            'lab1' => 16,
            'lab2' => 17
        );

        //Look for supported lab in first segment
        if( array_key_exists($wildcard_1->value, $lab_channel_ids) ) {
            $where = array('channel_id' => $lab_channel_ids[$wildcard_1->value]);
            $url_slug = $wildcard_1->value;

            //Look to see if the second segment is a valid url_title in the correct channel
            if( $wildcard_2->isValidUrlTitle($where) ) {
                $url_slug .= '/'.$wildcard_2->value;
            }

            $router->redirect('research-labs/'.$url_slug);
        } else {
            $router->set404();
        }
    }
);
rsanchez commented 9 years ago

What version of EE? What if you make a route that only does set404, does that work?

jhenriksen commented 9 years ago

EE v2.10.1

I added the following and I get the same blank page:

    'test/:any' => function($router) {
        $router->set404();
    }
rsanchez commented 9 years ago

Just tested on EE 2.10.1 and it works as expected.

There might be a plugin in your 404 template causing a WSOD. Try setting $debug = 1 in your index.php and see if you can spot any PHP errors.

jhenriksen commented 9 years ago

Thanks for loading that into 2.10.1 and giving it a try.

I set $debug = 1 and I don't see any errors. The 404 page also works in EE templates when I call {redirect="404"}

I replaced the content in my 404 template with just plain text and gave it another try, but got the same result.

I tried setting Display Output Profiler and Display Template Debugging to Yes to see if that gave any hints:

(0.000016 / 1.29MB) - Begin Template Processing -
(0.000048 / 1.29MB) URI: research/labs/123xyz
(0.000066 / 1.29MB) Path.php Template: ./.
(0.000088 / 1.29MB) Retrieving Template
(0.000116 / 1.29MB) Retrieving Template from Database: ./.
(0.017578 / 1.35MB) Template Not Found
(0.017615 / 1.34MB) Template Type:
(0.017647 / 1.35MB) Parsing Site Variables

That looks really similar to Issue #2