S B
S B

Reputation: 1363

Zend framework 2 dynamic routing

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.

Upvotes: 1

Views: 2682

Answers (1)

Exlord
Exlord

Reputation: 5391

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

Upvotes: 3

Related Questions