Skip to content
Advertisement

Tag: twig

Reorganize array in twig

I want to invert my array so that the categories are first so that I can better manage my foreach later. I managed to achieve it, but merge has removed the same keys. And I should not add value as another item in the array. Default Array: After Merge: ( two records have been deleted :() What is he trying

Is it possible to make global macros in Twig 3?

I want to upgrade my Twig from very old version (2.x or even 1.x) to 3.3. In old version macros imported in top level template are available in all extened and included templates. And I have a bunch of templates where I need my macros (100+ and many embed blocks). I don’t want to import macros manually in evety template.

cache with dynamic pages

I am currently developing a WEB site on symfony 6 and during production testing I have a problem with the TWIG cache. Indeed, my site includes a page editing feature. So when rendering the first time, the page is rendered correctly. However, if the editor then modifies the page, and I return to the page is still the old version.

How to overwrite a html-element but keep the rest of a block?

I am extending a twig-template where i want to replace the line with Twig-template I tried to overwrite the layout_main_navigation by copying everything and changing the class of the div. But i am not happy with that solution as i have to copy and overwrite a lot blocks. How can i achieve replacing the class of the div and overwrite

add empty cell in dynamic twig table

Hi I’ve got the following array And I need to convert it into a table using twig, this is what i’ve achieved so far But i need to achieve this instead: This is my code so far: As you can see from the pictures I need to add an empty cell if the dynamic key in the array doesn’t exist,

Custom Twig filter from bundle: Unable to load the runtime

I’ve a small twig custom filter in my project created following https://symfony.com/doc/current/templating/twig_extension.html . As long as it sits in src/Twig, it works as expected. Now I’m trying to move it to a custom bundle (vendor/turbolabit/tli-base-bundle/src/Twig/) to make it reusable. I moved the two files: I tagged it in services.yaml: (I also tried as tags: [twig.extension], even if it would be

Advertisement