views:

138

answers:

2

I have been setting my routes in my application.ini file which works for all the ones i have setup. The problem is when there are multiple actions within that controller and i try to use the routes in other actions.

For instance i have created the following in my application.ini for paging and column sorting

resources.router.routes.search.route = "search/:page/:col/:sort/:limit/"
resources.router.routes.search.defaults.controller = search
resources.router.routes.search.defaults.page = 1
resources.router.routes.search.defaults.col = time
resources.router.routes.search.defaults.sort = default
resources.router.routes.search.defaults.limit = 50
resources.router.routes.search.reqs.page = \d+
resources.router.routes.search.reqs.col = \w+
resources.router.routes.search.reqs.sort = \w+
resources.router.routes.search.reqs.limit = \d+

The above works when I'm on the default action of that page like

www.mywebsite.com/search/2/

Would bring up the second page of the results. But if I try the same on another action,

www.mywebsite.com/search/action/2

It just shows a blank page. I tried creating its own settings in the ini and that did not work. I've run across this problem before but usually just gave up and separated things into different controllers but i would rather have different actions.

Any help would be much appreciated.

Matt

A: 

search/:page/:col/:sort/:limit/ doesn't match www.mywebsite.com/search/action/2. Your route is looking for search/ followed by a digit (\d) that represents the page number; however, you're requesting search/ followed by the string action. I would suggest adding another parameter to your route: search/:action/:page/:col/:sort/:limit, defaulting action to index.

Requesting the first page of the default action stays the same (search). Requesting page 2 of the default route will now be search/index/2/, but you can now specify a different action (search/action/2).

Jordan Ryan Moore
Thank you for you input, I have actually tried that already but ended up with the same results. The funny thing is i do the search again, it will default to that second page, but when the url params are there the page will not load. I'm almost at a point where i'm going to separate it to it's own controller. The only other routing i have is similar but for a different controller. Would there be a better way of implementing the paging across all controllers and actions?
Matt
Below is what i recently tried based off another post I found but it still doesn't work. The weirdest thing, is that if i search on that page, then click on the paging, it comes up blank, but if i search again it defaults to page two because it can read the params in the browser, just wont page for some reason. I'll add my other portion of my application.ini below this comment since i'm running out of room in this comment
Matt
resources.router.routes.searchadvanced.route = "search/advanced/:page/:limit/"resources.router.routes.searchadvanced.defaults.controller = searchresources.router.routes.searchadvanced.defaults.action = advancedresources.router.routes.searchadvanced.defaults.page = 1resources.router.routes.searchadvanced.defaults.limit = 25resources.router.routes.searchadvanced.reqs.page = \d+resources.router.routes.searchadvanced.reqs.limit = \d+The post that gave me this ideahttp://stackoverflow.com/questions/1850558/php-zend-route-config-ini-similar-patterns
Matt
A: 

Turns out I completely forgot to set the variable for the search term. When on a new page it was not maintaining the original search term, and there for my code was doing what it was suppose to, and not display any output.

For those that think they have run into similar issues as this, they may find this link very helpful.

link text

Matt