jimgwhit said:
Search laravel 5 pagination you will find answer.
The "Customizing The Paginator URI" solve my problem, but i don´t want customize url everytime and also i wan´t to have full URL included in my HTML, not just a part of it...
jimgwhit said:
Full is there, you use relative to achieve this.
I´m sorry but i don´t understand you now. Tha alternative which i use now is
{!! str_replace('/?', '?', $items->render()) !!}
However i think that there should be some better solution...
You did not show controller code, that would help.
Did you read. http://laravel.io/forum/11-13-2014-laravel-5-pagination
I also have problems with the base uri in pagination.
Are you using homestead or something like xampp?
Read
http://laravel.io/forum/11-13-2014-laravel-5-pagination.
Showing your controller and view code would help.
I´m using xammp
Controller:
/**
* Display the specified resource.
*
* @param string $slug
* @return Response
*/
public function show($username, $slug, $section = null)
{
try {
$item = Item::bySlug($slug)->published()->firstOrFail();
switch ($section) {
case 'comments':
$data = $item->comments()->paginate(Item::$comments_per_page);
break;
case 'reviews':
$data = $item->reviews()->paginate(Item::$comments_per_page);
break;
default:
$section = 'item';
$data = null;
break;
}
return view('items.show', ['item' => $item, 'data' => $data, 'section' => $section]);
} catch (ModelNotFoundException $e) {
return Response::make('Not Found', 404);
}
}
Code in view:
{!! $data->render() !!}
Current fix:
{!! str_replace('/?', '?', $data->render()) !!}
And yes, i readed the documentation already. I use it always. However this is some kind of problem which i can´t figure out how to fix it.
Did you read the whole thing, like the part about
Pagination::makeLengthAware .......
I promise you paginate like in the post I refered you to and all will work. No other way.
Also, check your vars, does a var have a / at the end?
This must be xampp related. I have to render pagination like this:
$object->setPath('')->appends(Input::query())->render()
If I don't use setPath('')
, the trailing slash appears.
I call it from a macro, so I never have to manually specify ->setPath('')
.
micaweb said:
This must be xampp related. I have to render pagination like this:
$object->setPath('')->appends(Input::query())->render()
If I don't use
setPath('')
, the trailing slash appears.I call it from a macro, so I never have to manually specify
->setPath('')
.¨
The slash is still here, however if you use homestead instead of ex. xampp its going to work correctly even with the slash before the query string.
@miro4994 Homestead is yet another development environment.
But in my production server the pagination links are invalid due to the trailing slash. I know there is a workaround (calling setPath()).
@micaweb But is there any better solution?
@astroanu : It is not really a solution because it is not a HTTP error. The answer status will be 200 and not 404 here. And I would like that the answer will be 404 and not 200.
Lily lara
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community