简体   繁体   中英

CakePHP: Remove “page:#” from url params

I have a search form using the get method. The form works fine until I use it after paginating through the results.

Users can enter the site from any number of urls that look like domain.com/serach/results/something/something_else/ the important part is the domain.com/serach/results/ .

Here's what my code for the the form looks like:

echo $this->Form->create(null, array(
    'type' => 'get',
    'url' => $this->Html->url(null, true),
));

This will make the form look like this:

<form action="http://domain.com/serach/results/something/something_else/" method="get">

The problem is that when I paginate the results it adds the page:2 or page:3 to the action so it looks like:

<form action="http://domain.com/serach/results/something/something_else/page:3" method="get">

Is there a built in function in CakePHP that lets me remove the page:3 from the url that's being passed to the form action or am I going to have to create a function that looks for and removes the page:# ?

just set your url the verbose way:

'url' => array('controller' => 'x', 'action' => 'y') + $this->request->params['pass']

Done!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM