views:

298

answers:

1

I'm having a problem with chaining some routes using another variable at the end. I'm using wild card sub domains. Like this: http://eric.mysite.dev/mypage1 mypage1 is going to be a GET variable. So what I want is http://mysite.dev/donate/now/index/id/eric/pagename/mypage1

I have it working fine without the pagename like this:

$router=$fc->getRouter();
// Host routes
$accountHostRoute = new Zend_Controller_Router_Route_Hostname(':urlname.mysite.dev', array('module' => 'donate', 'controller' => 'now', 'action' => 'index'), array('urlname'=>'(?!www$).*')
        );

        // Account routes
        $router->addRoute('donateWithHostNameLocal', $accountHostRoute->chain(
            new Zend_Controller_Router_Route_Hostname(
                ':urlname.mysite.dev',
                array(
                    'module' => 'donate',
                    'controller' => 'now',
                    'action' => 'index'
                )
            )
        ));

But I also want the page name, so I tried this but it's not working:

    // Account dynamic pages routes
    $router->addRoute('donateWithHostNamePageNameLocal', $accountHostRoute->chain(
        new Zend_Controller_Router_Route_Hostname(
            ':urlname.mysite.dev/:pagename',
            array(
                'module' => 'donate',
                'controller' => 'now',
                'action' => 'index'
            )
        )
    ));

I get an application error of: Message: Resource 'default:mypage1' not found

Stack trace: 0 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Acl.php(751): Zend_Acl->get('default:mypage1') 1 /Applications/MAMP/htdocs/mysite/application/modules/default/plugins/AccessCheck.php(15): Zend_Acl->isAllowed('guest', 'default:mypage1', 'index') 2 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Controller/Plugin/Broker.php(309): Plugin_AccessCheck->preDispatch(Object(Zend_Controller_Request_Http)) 3 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Controller/Front.php(933): Zend_Controller_Plugin_Broker->preDispatch(Object(Zend_Controller_Request_Http)) 4 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch() 5 /Applications/MAMP/bin/php5/lib/php/ZendFramework-1.9.6/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run() 6 /Applications/MAMP/htdocs/mysite/public/index.php(34): Zend_Application->run() 7 {main}

Request Parameters: array ( 'controller' => 'mypage1', 'action' => 'index', 'module' => 'default', )

+1  A: 

I'd suspect your ACL doesn't have this resource defined and you use custom logic to generate the resources.

Tomáš Fejfar
It would help if you wrote which exception it throws (Zend_Acl_Exception, Zend_Application_Exception, ...)
Tomáš Fejfar
Character limit here, so I added the stack trace to my question.I do have guest privileges for donate/now/index in my ACL modelthank you
EricP
Then it's obvious that your route doesn't match. You can try adding /* to the end to match also woth parameters.
Tomáš Fejfar