…to check bundle's docs, probably they have flexibly configuration. For example, they allow you to choose ready-to-use templates among which there's a bootstrap template with correct classes, see: https://www.babdev.com/open-source/packages/pagerfanta/docs/3.x/views
Cheers!
|
|
// ... lines 1 - 14
|
|
class MainController extends AbstractController |
|
{ |
|
#[Route('/', name: 'app_homepage')] |
|
public function homepage( |
|
|
// ... lines 19 - 25
|
|
): Response |
|
{ |
|
$validSorts = ['purpose', 'leaveAt']; |
|
$sort = in_array($sort, $validSorts) ? $sort : 'leaveAt'; |
|
$pager = Pagerfanta::createForCurrentPageWithMaxPerPage( |
|
new QueryAdapter($voyageRepository->findBySearchQueryBuilder($query, $searchPlanets, $sort, $sortDirection)), |
|
|
// ... lines 32 - 33
|
|
); |
|
|
// ... lines 35 - 42
|
|
} |
|
} |
See Code Block in Script
…2",
"doctrine/orm": "^2.15.1",
"knplabs/knp-markdown-bundle": "^1.10.0",
"knplabs/knp-time-bundle": "^1.20.0",
"pagerfanta/doctrine-orm-adapter": "^4.1",
"pagerfanta/twig": "^4.1",
"sensio/framework-extra-bundle": "^6.2",
"stof/doctrine-extensions-bundle": "1.7.1",
"symfony/asset"…
…time!
Not exactly, when I'm showing 10 items per page, and there are 100 items, but only 50 are published, Pagerfanta still show 10 pages.
Seems there is no solution, because Pagerfanta can't control the data reicieved of QuieryBuilder.
Have a nice day :)
…What I mean is, if you are showing 10 items per page, and there are 100 items, but only 50 are published, you would still want Pagerfanta to show 10 pages. Is that correct?
If so, I might be missing some detail. The code you…
…twig` template, which should be this one: https://github.com/BabDev/Pagerfanta/blob/3.x/lib/Twig/templates/twitter_bootstrap5.html.twig... which really just extends this one: https://github.com/BabDev/Pagerfanta/blob/3.x/lib/Twig/templates/twitter_bootstrap4.html.twig
Anyways, I…
…Symfony 6 without removing those deprecations)?
The second source is BabDev\PagerfantaBundle. That module is at ^2.0 in composer.json. When I upgraded to version 3, Symfony blew up with a failed to open stream error. Is there any direction on upgrading Pagerfanta?
Thanks!
…both prev_message and next_message are hardcoded.
To render pagerfanta/twig templates you should use following configuration:
```
babdev_pagerfanta:
default_view: twig
default_twig_template: '@BabDevPagerfanta/twitter_bootstrap5.html.twig'
```
This uses \PagerFanta\Twig\View\TwigView which directly renders all the templates that resolve…
…And so, it seems as if the strings just aren't being sent through the translator. It's possible this is a bug. I checked the pagerfanta templates, and the strings ARE run through |trans, but the templates are complex, including some templates in the…
…it in twig similarly
`{{ pagerfanta(pager)|trans(pager.???, 'pagerfanta') }}`? But it's the whole object and nothing instead of the question marks seemed to fit.
I've found a solution by just exchanging the prev/next_message in the DefaultTemplate found in the pagerfanta vendor…
…Its constructor has two parameters: a query to get the collection of items and a query to get the total number of items.
Here is the code:
```
use Doctrine\ORM\QueryBuilder;
use Pagerfanta\Adapter\AdapterInterface;
/**
* Class CustomORMAdapter
* @package AppBundle\Pagination
*/
class CustomORMAdapter implements AdapterInterface
{
/**
* @var…
…
$adapter = new Queryadapter($queryBuilder);
$pagerfanta = Pagerfanta::createForCurrentPageWithMaxPerPage(
$adapter,
$request->query->get('page', 1),
9
);
$vehicles = $vehicleRepository->findAll();
$myVehicle = $vehicles[array_rand($vehicles)];
return $this->render('main/homepage.html.twig', [
'myVehicle' => $myVehicle,
'vehicles' => $vehicles,
'pager' => $pagerfanta,
]);
}
```
and finally this…
…
$pagerfanta = Pagerfanta::createForCurrentPageWithMaxPerPage(
$adapter,
$request->query->get('page', 1),
10
);
return $this->render('article_files/list.html.twig', [
'pager' => $pagerfanta,
]);
}
```
With this setup, you can search for something. And then, when you go to "page 2" of the results, Pagerfanta will keep the…
… I was stuck for a while getting pagerfanta to work but that's fine now. The docs for pagerfanta were a bit confusing because the link for the symfony framework on the babdev site took me to a github page instead of the babdev page…
x
94