511 search results

Custom Entity Methods & Twig Magic

…the vote count. Pass these in: $prefix then the absolute value of $this->votes... since we're adding the negative sign in manually. We can now use this nice method anywhere in our app... like from inside a template with mix.getVotesString(). Or shorten this…

7:46
Turbo-Friendly JavaScript

…into the body of your page, then it does work like normal. Open up templates/base.html.twig and - anywhere in the body, I'll go to the bottom - add a script tag and console.log('body executing!'). Refresh now. We see all three logs…

6:56
Ajax Element Reloading Controller

…an Ajax call to reload the product list area after a new product is successfully added. To be extra cool - cause we are extra cool - we're going to make this new controller generic so we can reuse it anywhere... like on the cart page…

6:23
Sub Request Attributes

…argument. If we try, I want an exception to be thrown. By the way, it is actually possible to use the RequestStack from anywhere to get the "master" request: it has a getMasterRequest() method. But! If you're using HTTP caching with edge side includes…

9:05
Page-Specific JS: Multiple Entries

…that we have this new article_show entry, inside show.html.twig, instead of our manual