rsanchez / resource_router

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

Channel rules outside of structure that default to native structure routing #10

Closed siebird closed 10 years ago

siebird commented 10 years ago

Hey Rob,

I'm having trouble wrapping my head around the rules needed for landing pages (outside of structure) without conflicting with structure pages from segment_1. I have two channels for the landing pages: landing_page & confirmation_page (for goal tracking). How would I default back to Structure after the conditionals?

    ':any' => function($router, $wildcard) {
        $landing = array('status' => 'Open', 'channel_id' => 14),
        $confirm = array('status' => 'Open', 'channel_id' => 16);

        // is the current page a landing page?
        if ($wildcard->isValidUrlTitle($landing)) {
            $router->setTemplate('site/landing_page');
        // is the current page a confirmation page
        } else if ($wildcard->isValidUrlTitle($confirm)) {
            $router->setTemplate('site/confirmation_page');
        // default to structure
        } else {

        },
rsanchez commented 10 years ago

You shouldn't have to do anything else:

    ':any' => function($router, $wildcard) {
        $landing = array('status' => 'Open', 'channel_id' => 14),
        $confirm = array('status' => 'Open', 'channel_id' => 16);

        // is the current page a landing page?
        if ($wildcard->isValidUrlTitle($landing)) {
            $router->setTemplate('site/landing_page');
        // is the current page a confirmation page
        } else if ($wildcard->isValidUrlTitle($confirm)) {
            $router->setTemplate('site/confirmation_page');
        }
        // dont do anything else, let native EE routing take place
    },
siebird commented 10 years ago

Hmm, this seems to break everything now. Do you see any formatting issues?

$config['resource_router'] = array(
    ':any' => function($router, $wildcard) {
        $landing = array('status' => 'Open', 'channel_id' => 14),
        $confirm = array('status' => 'Open', 'channel_id' => 16);

        // is the current page a landing page?
        if ($wildcard->isValidUrlTitle($landing)) {
            $router->setTemplate('site/landing_page');
        // is the current page a confirmation page
        } else if ($wildcard->isValidUrlTitle($confirm)) {
            $router->setTemplate('site/confirmation_page');
        }
    },
);
rsanchez commented 10 years ago

Can you install the develop branch and see if that resolves it for you? There are some changes related to the :any wildcard in there.

siebird commented 10 years ago

Still throwing the 'white screen' on both front-end & CP

rsanchez commented 10 years ago

Typo in the example,

        $landing = array('status' => 'Open', 'channel_id' => 14),

Should end with semicolon, not comma

        $landing = array('status' => 'Open', 'channel_id' => 14);
siebird commented 10 years ago

Dagnabbit! All squared now.