views:

1350

answers:

2

Hi,

I would like to know the .ini config file setup to make a route wherein the page number parameter is optional so that

http://news.mysite.com/national
http://news.mysite.com/national/1

point to the same page.

I have the code as follows

resources.router.routes.news_list.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.news_list.route = "([a-zA-Z0-9\-]+)/([0-9\-]+)"
resources.router.routes.news_list.defaults.module = "news"
resources.router.routes.news_list.defaults.controller = "index"
resources.router.routes.news_list.defaults.action = "category"
resources.router.routes.news_list.defaults.page = 1
resources.router.routes.news_list.map.1 = "categ"
resources.router.routes.news_list.map.2 = "page"
resources.router.routes.news_list.reverse = "%s/%s"

can some1 help me out with a solution to modify this code to make it work for both urls

+1  A: 

You can do this without the regex route using:

routes.news_list.route = ":action/:page"
routes.news_list.defaults.module = "news"
routes.news_list.defaults.controller = "index"
routes.news_list.defaults.action = "category"
routes.news_list.defaults.page = 1

I assume that you want every request to go to the "news" module and the "index" controller. Only the action and the page are variable in the url.

smack0007
Thanks Dude :-)
Nizam
A: 

This worked perfect for me after implementing smack0007's suggestion

resources.router.routes.news_list.route = ":categ/:page"
resources.router.routes.news_list.defaults.module = "news"
resources.router.routes.news_list.defaults.controller = "index"
resources.router.routes.news_list.defaults.action = "category"
resources.router.routes.news_list.defaults.page = 1

Thanks dude :-)

Nizam