…the `Unknown "pagerfanta" function.` error after getting pagerfanta/twig. I am using the same version(3.3). Are there additional setup that I need to do? I saw this in the docs but am unsure: https://www.babdev.com/open-source/packages/pagerfanta/docs/3…
|
|
// ... lines 1 - 9
|
|
<div class="container"> |
|
|
// ... lines 11 - 15
|
|
<div class="row"> |
|
{% for question in pager %} |
|
|
// ... lines 18 - 47
|
|
{% endfor %} |
|
|
|
{{ pagerfanta(pager) }} |
|
</div> |
|
</div> |
|
|
// ... lines 53 - 55
|
See Code Block in Script
|
|
// ... lines 1 - 20
|
|
class ProgrammerController extends BaseController |
|
{ |
|
|
// ... lines 23 - 78
|
|
public function listAction(Request $request) |
|
{ |
|
|
// ... lines 81 - 95
|
|
$response = $this->createApiResponse([ |
|
'total' => $pagerfanta->getNbResults(), |
|
'count' => count($programmers), |
|
'programmers' => $programmers, |
|
], 200); |
|
|
|
return $response; |
|
} |
|
|
// ... lines 104 - 202
|
|
} |
See Code Block in Script
Thanks for this awesome tutorial. I am wondering if there is any way to adapte Pagerfanta with Twig orders. (I know how to custmize it by QueryBuilder)
For example:
Let's say I need to use "If statements" like this:
```twig
{% for activity in pager…
Hey @mysiar,
Cool! Then it should work I suppose - make sure the Pagerfanta navigation links hold those specific query parameters in their URLs and it just should work. IIRC Pagerfanta should hook those query parameters itself, i.e. it should build all navigation URLs based…
|
|
// ... lines 1 - 17
|
|
class QuestionController extends AbstractController |
|
{ |
|
|
// ... lines 20 - 32
|
|
public function homepage(QuestionRepository $repository) |
|
{ |
|
$queryBuilder = $repository->createAskedOrderedByNewestQueryBuilder(); |
|
|
|
$pagerfanta = new Pagerfanta(new QueryAdapter($queryBuilder)); |
|
$pagerfanta->setMaxPerPage(5); |
|
|
|
return $this->render('question/homepage.html.twig', [ |
|
'pager' => $pagerfanta, |
|
]); |
|
} |
|
|
// ... lines 44 - 85
|
|
} |
See Code Block in Script
|
|
// ... lines 1 - 17
|
|
class QuestionController extends AbstractController |
|
{ |
|
|
// ... lines 20 - 32
|
|
public function homepage(QuestionRepository $repository, Request $request) |
|
{ |
|
|
// ... lines 35 - 36
|
|
$pagerfanta = new Pagerfanta(new QueryAdapter($queryBuilder)); |
|
$pagerfanta->setMaxPerPage(5); |
|
$pagerfanta->setCurrentPage($request->query->get('page', 1)); |
|
|
// ... lines 40 - 43
|
|
} |
|
|
// ... lines 45 - 86
|
|
} |
See Code Block in Script
…Yes, in PageFranata the links are the same as the one which goes from/to the LiveComponent Ajax, but (obviously) GET not POST.
So I now have the idea of replacing the hrefs with actions or somehow replacing all the default PageFranta elements with buttons…
|
|
// ... lines 1 - 20
|
|
class ProgrammerController extends BaseController |
|
{ |
|
|
// ... lines 23 - 78
|
|
public function listAction(Request $request) |
|
{ |
|
|
// ... lines 81 - 90
|
|
$programmers = []; |
|
foreach ($pagerfanta->getCurrentPageResults() as $result) { |
|
$programmers[] = $result; |
|
} |
|
|
// ... lines 95 - 102
|
|
} |
|
|
// ... lines 104 - 202
|
|
} |
See Code Block in Script
…php
public function findIncompleteOrderByDroidCount(): Pagerfanta
{
$qb = $this->createQueryBuilder('s')
->leftJoin('s.droids', 'droid')
->addSelect('COUNT(droid) AS HIDDEN droidCount')
->andWhere('s.status != :status')
->groupBy('s.id')
->orderBy('droidCount', 'ASC')
->setParameter('status', StarshipStatusEnum::COMPLETED);
$query = $qb->getQuery();
return new Pagerfanta(new QueryAdapter($query))…
…component - it should work great I think, give it a try. Thankfully, Pagerfanta has some useful methods that you can leverage to see if you need to show Next/Previous.
> And, um, how do I apply this to a full widget?
Are you talking…
…possible, why not? :) We were talking about Pagerfanta in this tutorial, in this specific chapter: https://symfonycasts.com/screencast/last-stack/pager-sorting - that's how to use Pagerfanta, or you can search more related videos about it on SymfonyCasts: https://symfonycasts.com/search?q=pagerfanta…
…babdev/pagerfanta-bundle": "4.x-dev", // 4.x-dev
"doctrine/doctrine-bundle": "^2.10", // 2.12.x-dev
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.4.x-dev
"doctrine/orm": "^2.16", // 2.18.x-dev
"knplabs/knp-time-bundle": "dev-main", // dev-main
"pagerfanta…
…feature-rich, though Pagerfanta might be older that's why Ryan just got to use to it :) Feel free to use any of it that you like more... or know better. Though Pagerfanta seems more active (at least the bundle) lately with their releases.
Cheers!
|
|
// ... lines 1 - 4
|
|
{% block body %} |
|
<div class="flex"> |
|
|
// ... lines 7 - 13
|
|
<section class="flex-1 ml-10"> |
|
|
// ... lines 15 - 82
|
|
<div class="flex items-center mt-6 space-x-4"> |
|
{{ pagerfanta(voyages) }} |
|
<a href="#" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Previous</a> |
|
<a href="#" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Next</a> |
|
</div> |
|
</section> |
|
</div> |
|
|
// ... lines 90 - 91
|
See Code Block in Script
|
|
// ... lines 1 - 4
|
|
{% block body %} |
|
<div class="flex"> |
|
|
// ... lines 7 - 13
|
|
<section class="flex-1 ml-10"> |
|
|
// ... lines 15 - 82
|
|
<div class="flex items-center mt-6 space-x-4"> |
|
{% if voyages.hasPreviousPage %} |
|
<a href="{{ pagerfanta_page_url(voyages, voyages.previousPage) }}" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Previous</a> |
|
{% endif %} |
|
{% if voyages.hasNextPage %} |
|
<a href="{{ pagerfanta_page_url(voyages, voyages.nextPage) }}" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Next</a> |
|
{% endif %} |
|
|
// ... lines 90 - 92
|
|
</div> |
|
</section> |
|
</div> |
|
{% endblock %} |
See Code Block in Script
|
|
// ... lines 1 - 4
|
|
{% block body %} |
|
<div class="flex"> |
|
|
// ... lines 7 - 13
|
|
<section class="flex-1 ml-10"> |
|
|
// ... lines 15 - 82
|
|
<div class="flex items-center mt-6 space-x-4"> |
|
{% if voyages.hasPreviousPage %} |
|
<a href="{{ pagerfanta_page_url(voyages, voyages.previousPage) }}" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Previous</a> |
|
{% endif %} |
|
{% if voyages.hasNextPage %} |
|
<a href="{{ pagerfanta_page_url(voyages, voyages.nextPage) }}" class="block py-2 px-4 bg-gray-700 text-white rounded hover:bg-gray-600">Next</a> |
|
{% endif %} |
|
<div class="ml-4"> |
|
Page {{ voyages.currentPage }}/{{ voyages.nbPages }} |
|
</div> |
|
</div> |
|
</section> |
|
</div> |
|
{% endblock %} |
See Code Block in Script
…ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^4.2",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.15",
"knplabs/knp-time-bundle": "^1.20",
"pagerfanta/doctrine-orm-adapter": "^4.2",
"pagerfanta/twig": "^4.2",
"sensio/framework-extra-bundle": "^6.2…
…see we have any filters in the course code of this tutorial, are you talking about your private project? Well, in short, Pagerfanta works via GET, i.e. you can see query parameters in the URL. So, your filter form also should work via GET…
I have a problem with pagination links and Symfony form.
When I submit my form I got filtered results but pagination links are just a tags and they do not submit the whole form with new page number
How to use pagerfanta with Symfony form …
x
94