Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How to I append search to pagination links?
frocco
May 2015
Hello,
pagination is working fine, but if I use get variable ($search) that results in 2 pages, the second page url only shows page=2, not page=2&search=whatever
How do I append my search to the pagination links?
Thanks
Harro
May 2015
Update your local framework installation to either 1.7.3 (released last week) or switch to 1.8/develop.
The issue was fixed here:
https://github.com/fuel/core/commit/b952d60cac99137f973633238addd540790cf45d
frocco
May 2015
Hi Harro,
I downloaded 1.7.3 and replaced the core and packages folders.
I might be upgrading wrong, as this did not resolve the issue.
[code]
$query = Model_Category::query();
$search = INput::get('search');
if (!empty($search))
{
$query->where('name','like','%'.$search.'%');
}
//
->rows_offset($pagination->offset)
//
->rows_limit($pagination->per_page)
// ->get();
$config = array(
'pagination_url' => Uri::current(),
'total_items' => $query->count(),
'per_page' => 10,
'uri_segment' => 'page',
);
$data['pagination'] = Pagination::forge('mypagination', $config);
$data['categories'] = $query
->limit($data['pagination']->per_page)
->offset($data['pagination']->offset)
->get();
echo Pagination::instance('mypagination')->render();
[/code]
Harro
May 2015
Accepted Answer
You are passing a "pagination_url".
That will disable any URL detection by the pagination class, it will use the url you have defined, as you defined it.
So either remove that and let the class construct the URL itself, or pass a URL in the config that includes the current query string.
frocco
May 2015
Thank you, it is working now.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
frocco
May 2015
Harro
May 2015