Chapters
27 Chapters
|
2:45:18
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
27.
Themed Pagination Links
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^3.3", // v3.3.0
"composer/package-versions-deprecated": "^1.11", // 1.11.99.3
"doctrine/doctrine-bundle": "^2.1", // 2.4.2
"doctrine/doctrine-migrations-bundle": "^3.0", // 3.1.1
"doctrine/orm": "^2.7", // 2.9.5
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"knplabs/knp-time-bundle": "^1.11", // v1.16.1
"pagerfanta/doctrine-orm-adapter": "^3.3", // v3.3.0
"pagerfanta/twig": "^3.3", // v3.3.0
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"stof/doctrine-extensions-bundle": "^1.4", // v1.6.0
"symfony/asset": "5.3.*", // v5.3.4
"symfony/console": "5.3.*", // v5.3.7
"symfony/dotenv": "5.3.*", // v5.3.7
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.3.*", // v5.3.7
"symfony/monolog-bundle": "^3.0", // v3.7.0
"symfony/runtime": "5.3.*", // v5.3.4
"symfony/stopwatch": "5.3.*", // v5.3.4
"symfony/twig-bundle": "5.3.*", // v5.3.4
"symfony/validator": "5.3.*", // v5.3.14
"symfony/webpack-encore-bundle": "^1.7", // v1.12.0
"symfony/yaml": "5.3.*", // v5.3.6
"twig/extra-bundle": "^2.12|^3.0", // v3.3.1
"twig/string-extra": "^3.3", // v3.3.1
"twig/twig": "^2.12|^3.0" // v3.3.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", // 3.4.0
"symfony/debug-bundle": "5.3.*", // v5.3.4
"symfony/maker-bundle": "^1.15", // v1.33.0
"symfony/var-dumper": "5.3.*", // v5.3.7
"symfony/web-profiler-bundle": "5.3.*", // v5.3.5
"zenstruck/foundry": "^1.1" // v1.13.1
}
}
19 Comments
I got a new job where symfony is highly used framework. Your symfony videos helped me understand it.
I still think doctrine is a little bit confusing (compared to laravel eloquent) but I think I can get used to it.
Thanks! :)
Congratulations Michael M.!
We can't be happier to hear our tutorials helped you landing a new job! Cheers!
Hello, I have a small problem with the final pagination translation. I want to translate the Previous and Next to czech, but making pagerfanta.cs.yaml didn't work, I've also found the translations included with pagerfanta so it should translate by itself, but it's not.
My services.yaml is:
parameters: locale: 'en'and translation.yaml:Hey Matěj V.!
Hmmm. I do NOT know what's going on, but let's dig in a little bit. First, I'd clear your cache manually - JUST in case -
bin/console cache:clear. At one time, Symfony had a bug where it wouldn't see new translation directories until you cleared cache. So, do this just in case.When you refresh this page, and look down in the web debug toolbar, you should see a little translation icon. If you click that, it should show you the "missing translations". Do you see "Previous" and "Next" as missing translations? Or does it look like it IS finding those translations? Have you successfully translated other strings (just normal stuff in your own code) on your site? I'm asking in case there is some problem with the locale itself.
I'm not sure what's going on here, but it must be something minor: I agree that you should be getting automatic translations from the bundle, even if you did nothing else.
Cheers!
Thanks for the reply weaverryan !
Clearing cache unfortunately didn't help.
Yes I don't see the translation icon, it behaves like there's nothing to translate on cs locale, only when i add |trans, it expects the whole html block of the pagination, not just for previous or next.
I already did add some translations before, like the security one from the security tutorial here and they worked without a prob. Should I call 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, but that's not an ideal one :D.
Hey Matěj V.!
> Yes I don't see the translation icon
You don't see the translation icon at all? What if you, somewhere else in the main template, try to translate some new, invented string that is not in a translation file? Do you see the translation icon THEN? And does it just show the ONE missing translation (for the key you just invented) or other things?
The fact that you have translated other strings tells me the translator is installed and working (this seems like an obvious point, but a likely tripping point is not having the translator installed, in which case you don't get an error, but the translation system doesn't do anything). 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 bundle that override those in the main library. It's possible something got messed up and the wrong templates are being used. To test that theory, you could tweak some core pagerfanta templates to see what happens.
For example, if you find this template and change Next to TEST - https://github.com/BabDev/P... - if everything is working correctly, you should NOT see a change. That's because this template is overridden (or should be) by the bundle. IF you DO see a change, then there's a bug with how the bundle is not overriding this template. Here is the template that SHOULD be used, and where you can see the |trans filter: https://github.com/BabDev/P...
Cheers!
Hi weaverryan !
I've been dealing with the exact same issue and I actually found the reason why is it not translating (and even not showing defined messages). The problem is in the bundle configuration of the <b>default_view</b>.
In the video, you are setting the value to <b>twitter_bootstrap5</b>. This resolves as pagerfanta core <b>\PagerFanta\View\TwitterBootstrap5View</b> class which uses <b>\PagerFanta\View\Template\TwitterBootstrap5Template</b>. Its method <b>getDefaultOptions</b> extends array from parent where both <b>prev_message</b> and <b>next_message</b> are hardcoded.
To render <b>pagerfanta/twig</b> templates you should use following configuration:
This uses <b>\PagerFanta\Twig\View\TwigView</b> which directly renders all the templates that resolve translations and these also show up in the web debug toolbar. The template can be specified using <b>default_twig_template</b> option.
Anyway, thanks a lot for the great work with the casts, this package always seemed too complex to me and thanks to this video I find it as easy as a breeze.
Awesome course! Thank you @weaverryan !
Great job!! I begun appliying the knowledge: a budget control for a construction company. I got a paginnated page when I edit something there would like to return to the same page I was, haven't been able to find a way to do it, any ideas
Hey alcb1310
In your Edit controller you can just return a Redirect reponse to the route he's supposed to return. If that's not useful for you, perhaps you can use the request referer
Cheers!
thanks, used the request referer and was a success
Great job once again on this toot. I have begun applying this knowledge to a personal project: a scheduling and billing system for my wife's psychology practice. Ambitious, I know.
Hey davidmintz
Thanks for the feedback, we are happy to know that you have where to apply knowledge!
Cheers!
Hi, I still get 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...
Hey Ccc123!
Hm, what did you do? Are you trying to call pagerfanta() Twig function in your template? If so, it looks like the bundle isn't installed/enabled in your project. Make sure you installed it via Composer, Symony Flex should enable it for you in bundles.php files.
Cheers!
Hi Víctor, I have the same problem, I've been searching about the problem and I found that I need to add a bundle in bundles.php but what bundle I need to add?
Hey Temolzin,
First of all, what bundle did you install? :) I suppose you installed https://github.com/BabDev/PagerfantaBundle ? If so, please, make sure it's enabled in your bundles.php file. Specifically, check the docs: https://www.babdev.com/open-source/packages/pagerfantabundle/docs/3.x/installation
Also, try to clear the cache just in case :)
I hope this helps!
Cheers!
Hi Victor,
I followed the videos to the point where
{{ pagerfanta(pager) }}was added to the template and then I didcomposer require pagerfanta/twig"Houston: no signs of life"
Start the conversation!