I have a problem going from page one to page two, three, four, etc… when using pagination along with a long and variable query string. I suspect its a routing issue. I’m using a custom query that the user selects with a series of dropdown menus. The resulting url is very long which contains all of the post variables.
For example, the working first page url looks like (with the post variables represented here as letters):
project/web/s/search_results/t/u/v/w/x/y/z
…and the non-working 2nd page url when page 2 is clicked:
project/web/s/search_results?page=2
The 2nd page is following the routing rule. As mentioned page two doesn’t work as clicked from the pager menu. But if I manually type in:
project/web/s/search_results/t/u/v/w/x/y/z?page=2
-it does work. The important lines of code are as follows:
Routing rule:
search_results:
url: /s/search_results
param: { module: s, action: search_results }
url_for helper in pagination:
<?php foreach ($pager->getLinks() as $page): ?>
<?php if ($page == $pager->getPage()): ?>
<?php echo $page ?>
<?php else: ?>
<a href="<?php echo url_for('@search_results', $object) ?>?page=<?php echo $page ?>"><?php echo $page ?></a>
<?php endif; ?>
<?php endforeach; ?>
And the error message:
404 | Not Found | sfError404Exception
Unable to find the s object with the following parameters "array ( 'id' => 'search_results', 'sf_format' => 'html',)").
Should I be using a collection for the routing rule?
Edit:
The object referred to in the url_for helper:
<?php foreach ($pager->getResults() as $o => $object): ?>
Try: