Router::connect( '/products/:category', array( 'controller' => 'categories', 'action' => 'index' ), array( 'category' => '[-a-z]+', 'pass' => array('category') ) );
Router::connect( '/products/:category/:product', array( 'controller' => 'products', 'action' => 'view' ), array( 'category' => '[-a-z0-9]+', 'product' => '[-a-z0-9]+', 'pass' => array('category', 'product') ) ); That will work for one category level. You may need to adjust the regex to match your slug format. On Wed, Apr 17, 2013 at 2:45 AM, LDSign <fr...@lamozik.de> wrote: > Hi > > I am trying to make a special route, but had no success so far. Could you > help? > > The url looks like: > > /products/:category_slug/:product_slug > > > So, when "product_slug" isnt specified I would like to use > > array('controller' => 'categories','action' => 'index') > > > and in the other case (when "product_slug" is specified): > > array('controller' => 'products','action' => 'index') > > > For example: > > /products/category_a should point to /categories/index/category_a > > > and (note the same category_slug) > > /products/category_a/product_a should point to > /products/index/category_a/product_a > > > Is this possible and could you provide an example? > > Thank you very much, > Frank > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to cake-php+unsubscr...@googlegroups.com. > To post to this group, send email to cake-php@googlegroups.com. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.