2013-08-26 38 views
0

我有CakePHP的路线与子文件夹CakePHP的路线

Router::connect(
    '/catalog/:slug/:slug2/*', array(
     'controller'=>'pages', 
     'action'=>'view' 
)) 

一个问题,当我有网址 /catalog/something/page:2 - 它也抓住这个环节。但它不应该,因为在参数page:2之后没有斜线,如何解决它?谢谢!!

+0

我希望你已经阅读[文档](http://book.cakephp.org/2.0/en/development/routing.html)? – Blazemonger

+0

阅读并仍在阅读! – Gediminas

回答

1

我希望这可能会有所帮助。

Router::connect(
    '/catalog/:slug/:slug2/*', array(
     'controller'=>'pages', 
     'action'=>'view' 
), array('pass' => array('slug', 'slug2'))); 

并且在您的视图文件中,您可以这样编写以生成以上链接。

echo $this->Html->link('link', array(
    'controller' => 'pages', 
    'action' => 'view', 
    'slug' => 'slug', 
    'slug2' => 'slug2' 
)); 
+0

不行,它不起作用。如果我以你的方式提供链接,我会在网址中使用slug:x和slug2:x标签 - 我想避免这种情况。所以我认为没有理性的方法来做到这一点,现在我需要大量的解决方法,因为这个蛋糕错误 – Gediminas

+1

你想从'/ catalog/something/page:2'到'/ catalog/something /'' –

+1

如果是这样,那么你可以像这样传递'echo $ this-> Html-> link('link',array( 'controller'=>'pages', 'action'=>'view', 'page'=>'2' ));'而不是slu。。 –