1

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.

2
  • I suggest to first read ZF2Docs: Routing and Controllers and then for more details ZF2Docs: Zend Mvc Routing. Then you come back with what you have tried and we'll help you out ;) Commented May 10, 2013 at 6:26
  • For this kind of thing I would be tempted to extend one of the available routers to make a custom router to check your db / use caching Commented May 10, 2013 at 8:00

1 Answer 1

3

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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.