CakePHP regex route

I have a controller setup to accept two vars: /clients/view/var1/var2

And I want to show him how /var1/var2

So i try

Router::connect('/*', array('admin'=>false, 'controller' => 'clients', 'action' => 'view'));

But this stops all other controllers working as /*routes all

All other pages on the site are prefixed admin, so basically I need a route that is ignored if the current prefix admin! I tried this (regex from regex to match a string that doesn't contain a word? ):

Router::connect('/:one', array('admin'=>false, 'controller' => 'clients', 'action' => 'view'), array(
    'one' => '^((?!admin).*)$'
));

But I think the regex is wrong, because if I'm on /test, it asks for a test controller, not clients

My other routes:

Router::connect('/admin', array('admin'=>true, 'controller' => 'clients', 'action' => 'index'));
Router::connect('/', array('admin'=>false, 'controller' => 'users', 'action' => 'login'));

What am I doing wrong? Thank.

+3
2

. . , . , :

CakeBook , , . '/*', . , :

// the previously defined routes
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/admin', array('controller' => 'clients', 'action' => 'index', 'admin' => true));

// prefix routing default routes with admin prefix
Router::connect("/admin/:controller", array('action' => 'index', 'prefix' => 'admin', 'admin' => true));
Router::connect("/admin/:controller/:action/*", array('prefix' => 'admin', 'admin' => true));   

// the 'handle all the rest' route, without regex
Router::connect(
    '/*', 
    array('admin'=>false, 'controller' => 'clients', 'action' => 'view'), 
    array()
);

, /test 1/test2 .

+3

, - " " ( ):

Router::connect(
    '/clients/view/:var1/:var2/*',  
    array( 
        'controller' => 'clients',
        'action' => 'view'
    ),
    array( 
        'pass' => array( 
            'var1', 
            'var2' 
        ) 
    ) 
);

:

public function view($var1 = null, $var2 = null) { 
    // do controller stuff
}

(. " " ). "/*" , , , , .

0

All Articles