Question

I want to write routes for this type of urls

http://www.example.com/category/sub-category/id.html

here category is dynamic. means- i have 100 of categories in my db. sub category is also dynamic. i need to show page based on id value. Any one please suggest.

Was it helpful?

Solution

Try reading the docs first its very simple :

'sample' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/:category[/:sub_category[/:id]].html',
                    'defaults' => array(
                        'controller' => 'Your Controller',
                        'action' => 'Your Action',
                    ),
                ),
            ),

With this router config you can have :

http://www.example.com/category.html
http://www.example.com/category/sub-category.html
http://www.example.com/category/sub-category/id.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top