2

i have a blog with a routing. In my ini it seems like this:

routes.quote.route = :id
routes.quote.defaults.module = default
routes.quote.defaults.controller = posts
routes.quote.defaults.action = single
routes.quote.reqs.id = \d+

Now i want to have a page parameter (for comments) additionally. I only got it by creating a sectond route like this:

routes.quotePage.route = :id/page/:page
routes.quotePage.defaults.module = default
routes.quotePage.defaults.controller = posts
routes.quotePage.defaults.action = single
routes.quotePage.reqs.id = \d+
routes.quotePage.reqs.page = \d+

I want to combine these two into one. How can i do this? the page-parameter should only be additional.

Thank You

hakre
  • 193,403
  • 52
  • 435
  • 836
trialgod
  • 302
  • 1
  • 15

2 Answers2

-1

use Zend_Controller_Router_Route_Regex like this :

routes.quote.route.type = "Zend_Controller_Router_Route_Regex"
routes.quote.route = posts/(\d+)/(\d+)
routes.quote.defaults.module = default
routes.quote.defaults.controller = posts
routes.quote.defaults.action = single
routes.quote.map.1 = "id"
routes.quote.map.1 = "page"
Mouna Cheikhna
  • 38,870
  • 10
  • 48
  • 69
-1

You can assign a defaul value to page parameter

routes.quotePage.route = :id/:page
routes.quotePage.defaults.module = default
routes.quotePage.defaults.controller = posts
routes.quotePage.defaults.action = single
routes.quotePage.defaults.page = 1
routes.quotePage.reqs.id = \d+
routes.quotePage.reqs.page = \d+

This will match both http://domain.com/1 and http://domain.com/1/page/1 or http://domain.com/1/page/2

Optimus
  • 1,703
  • 4
  • 22
  • 41