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 <frank@lamozik.de> wrote:
HiI am trying to make a special route, but had no success so far. Could you help?The url looks like:/products/:category_slug/:product_slugSo, when "product_slug" isnt specified I would like to usearray('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_aand (note the same category_slug)/products/category_a/product_a should point to /products/index/category_a/product_aIs 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+unsubscribe@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+unsubscribe@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.
No comments:
Post a Comment