twig Questions

16

Solved

I'm getting this error message every time I try to submit the form: The CSRF token is invalid. Please try to resubmit the form My form code is this: <form novalidate action="{{path('signup...
Tansy asked 4/5, 2014 at 11:38

4

Solved

I'm trying to write a template in Twig. Inside it I would like it to perform some manipulations on the string data that comes from the controller. In particular, there's a common manipulation (conv...
Internationalist asked 12/9, 2018 at 13:13

2

I'm using twig templates in a slim framework app. I have a template page.phtml which paginates an array of data and has several sub blocks intended for overriding per element specifics like paginat...
Lynnett asked 27/12, 2013 at 18:57

3

Solved

I need to display an image in twig based on a value that comes from controller. For example there in an image of a home that should appear if the value coming from the controller is (Home or home o...
Emotion asked 27/10, 2015 at 6:15

7

Is it possible to inlcude code from a svg file directly into a twig template file? Something like: {% include 'my.svg' %} that will result in: <svg viewbox=".... />
Vlf asked 8/7, 2016 at 7:38

5

Solved

I have set the rendering of an navigation menu en an separate twig template. Reason is the the menu is generated on two different places in the application. Now I want to give a parameter to the ...
Hexahydrate asked 12/1, 2017 at 22:53

3

Solved

I'm trying to display all the users in my User object without knowing the structure of the object (so I can use the same table to display other collection of objects as well). This is what it woul...
Maurizio asked 4/2, 2014 at 19:17

4

The problem is very short. I have got an array with integer keys, and parameter which is the string. I want to get element of that array by using that parameter. How to get in Twig intval - (int)...
Arpent asked 30/6, 2014 at 11:18

16

How can I limit the length of the text, e.g., 50, and put three dots in the display? {% if myentity.text|length > 50 %} {% block td_text %} {{ myentity.text}}{% endblock %} {%endif%}
Shelbashelbi asked 30/10, 2012 at 16:0

3

Solved

I have container.twig including component.twig and passing an object called 'mock'. In container.twig: {% set mock = { title : "This is my title" } %} {% include 'component.twig' with mock %} ...
Excretory asked 28/4, 2016 at 16:0

2

Solved

I'm looking for a VS Code extension which help me autocomplete my HTML tag in twig files. I would like to write "h1", then press enter and get: <h1></h1> For now I installed ...
Asafetida asked 17/10, 2022 at 10:25

4

Solved

I'm using Twig lately and I was wondering if it is possible to output the template names which are loaded on the page. The best way I can think of is to display the name above the template itself a...
Vorous asked 2/2, 2016 at 14:48

2

I want to change something related to product attributes in the product details page: /index.php?route=product/product&product_id=100 So I changed \catalog\controller\product\product.php file ...
Drakensberg asked 30/4, 2020 at 10:11

3

Solved

In PHP I can do <?php if ($someVar): ?> This checks if a variable exists and if its value is different from a zero-like value like 0, null, '', and so on. Is there any way to do so in Twi...
Clemmie asked 17/1, 2018 at 13:22

2

In choiceType field I have parameter - choice label 'choice_label' => function ($pay, $key, $index) { return "<b>".$pay->getName()."</b><br />"; }, And render function...
Strangle asked 8/8, 2017 at 7:39

3

Solved

Is there a way to replace a GET parameter value from twig? For example, I have a page at this address: http://localhost/app_dev.php/test/?param1=40&sort=name And in my twig I want to build...
Springs asked 12/3, 2013 at 13:36

4

Solved

In PHP we can check if a key exists in an array by using the function array_key_exists(). In the Twig templating language we can check if an variable or an object's property exists simply by using...
Urinalysis asked 28/11, 2012 at 14:21

5

Solved

I trying to output an array from the database to the screen. In my entity: /** * @ORM\Column(type="array", nullable=true) */ private $category; In my twig template: {% for category in user.pr...
Cytolysin asked 13/10, 2014 at 12:33

8

Solved

I looked around for the code to get the current path in a Twig template (and not the full URL), i.e. I don't want http://www.sitename.com/page, I only need /page.
Cetology asked 21/2, 2012 at 13:49

5

Solved

How can I display a string that contains HTML tags in a twig template? My PHP variable contains this HTML and text: $word = '<b> a word </b>'; When I do this in my twig template: {{ wo...
Overtake asked 2/12, 2011 at 10:44

4

Solved

I'm having problems with the |date("d F, Y") filter in my twig templates. I want the months to be outputted in Swedish. I have tried setting "locale: sv" in my parameters.yml files but I get no ef...
Wynnie asked 28/6, 2013 at 11:57

5

Solved

I'd like to check if today's date is between two dates from the database. Here's my code. {% if today < room.price_start_date and today > room.price_end_date %} <a href="{{'/'|app}}/book/...
Polysaccharide asked 26/12, 2016 at 16:23

8

Solved

I am using twig to render a view and I am using the striptags filter to remove html tags. However, html special chars are now rendered as text as the whole element is surrounded by "". How can I ei...
Bimetallism asked 23/2, 2015 at 9:8

10

Solved

I want to generate table headers in a twig block and reuse them across the page, this page has about 5 different tables with roughly the same headers. The block code is such : {% block table_heade...
Cuttler asked 20/5, 2011 at 6:58

4

Solved

I'm trying to display all elements inside an array and separate them with a line break, but I can't get it work. Here is what I tried: {{ user.roles | join('<br/>') }} {{ user.roles | join...
Sepulcher asked 5/5, 2017 at 14:41

© 2022 - 2024 — McMap. All rights reserved.