-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paginator regression between v4.48 and v4.55 #9835
Comments
Should it not be |
Neither work. The issue was from this change where the view is cast to a string. I can't see any access to the |
Can you use |
That is an array for me, here is the full
Is there a reason why the default paginator view is explicitly set in Changing that line to the below means I can just use 'auto_links' => (string) $paginator->render(), |
This is how I'd handle pagination with Blade: @php($articles = Statamic::tag('collection:articles')->paginate(10)->fetch())
{!! $articles['paginate']['auto_links'] !!} I don't think we ever intended people doing what you were doing and changing the pagination view with As you mentioned, the pagination view is currently hard coded to use Illuminate\Pagination\Paginator;
public function boot(): void
{
Paginator::defaultView('pagination::tailwind');
} Would that work for you? |
Yep that works @duncanmcclean |
That'll be a breaking change so it'll be in v5. For now, you can override it yourself. Create a new paginator class in <?php
namespace App;
class LengthAwarePaginator extends \Statamic\Extensions\Pagination\LengthAwarePaginator
{
public function render($view = null, $data = [])
{
return static::viewFactory()->make(static::$defaultView, array_merge($data, [
'paginator' => $this,
'elements' => $this->elements(),
]));
}
} In your use Statamic\Extensions\Pagination\LengthAwarePaginator;
public function register()
{
$this->app->extend(LengthAwarePaginator::class, function ($paginator) {
return new \App\LengthAwarePaginator(
$paginator->getCollection(),
$paginator->total(),
$paginator->perPage(),
$paginator->currentPage(),
$paginator->getOptions()
);
});
} When you upgrade to v5 you can undo this. |
Bug description
I've just upgraded from v4.48 to v4.55 and the code I used to get the paginator is no longer working.
Is there a recommended way of using
Statamic::tag()
to get a custom pagination view?When on v4.48 the custom view is used
resources/views/vendor/pagination/tailwind.blade.php
. But now theLengthAwarePaginator
does not seem to be in the return array at all. Using$articles['paginate']['auto_links']
doesn't use the custom view.How to reproduce
Logs
No response
Environment
Installation
Existing Laravel app
Antlers Parser
None
Additional details
No response
The text was updated successfully, but these errors were encountered: