twig Questions

2

Solved

I'm trying to create a specific twig filter that can handle 2 parameters. $documentURL = new Twig_SimpleFilter('documentURL', function($DocumentId, $UserId){ $URL = "http://example.example.com/...
Papaya asked 25/2, 2014 at 18:45

9

Solved

Is is possible to decode JSON in twig? Googling doesn't seem to yield anything about this. Does decoding JSON in Twig not make sense? I'm trying to access 2 entity properties on an Symfony2's en...
Silverfish asked 24/1, 2013 at 11:50

8

Solved

I'm using symfony framework 3 to develop a web application. I need to add boostrap's functionality to my application. I installed bootstrap using the below command. (I'm using composer.) composer ...
Godgiven asked 6/4, 2016 at 13:45

5

For a example, if we pass a table object to the twig view, how can we get the class name of that object like 'Table'. class Table{ } $table = new Table(); In Twig: {{ table.className }} ---> ...
Broomstick asked 21/3, 2014 at 4:46

5

I'm not able to access template variable in TWIG macro. Here is a simplified example: {% set myname = "Ligio" %} {{ _self.pagedurl(1) }} {% macro pagedurl(page) %} Hi {{ _self.myname }}! This i...
Forethought asked 27/2, 2013 at 8:52

4

Solved

I know this is really trivial and not that important but it could save me some lifetime... You know you can declare variables in PHP in a if block if( $row = $sql->fetch ){ //do something with...
Resection asked 14/3, 2017 at 9:24

1

Background I want to display entity-independent information in the EDIT-page. According to the official documentation it can be solved with configureResponseParameters-function. Problem So I implem...
Contain asked 10/12, 2020 at 6:33

6

I'm wondering how to load a template from it's full path (like FILE constant give). Actually you have to set a "root" path for template like this : require_once '/path/to/lib/Twig/Autoloader.php'...
Barimah asked 15/8, 2011 at 12:31

5

Solved

How can I call the 'time_diff' function In Twig The code {{ post.created_at|time_diff }} Output The filter "time_diff" does not exist
Temperance asked 30/11, 2015 at 14:59

4

Solved

Is there a shorter syntax in Twig to output a conditional string of text? <h1>{% if not info.id %}create{% else %}edit{% endif %}</h1> Traditional php is even easier than this: <...
Bufordbug asked 11/11, 2012 at 22:23

6

Solved

I'm using the twig template engine while using symfony2. I'm trying to find a way to delete the white spaces from a text. For example, I play shall become Iplay. I've tried: Spaceless Trim ...
Toms asked 27/7, 2016 at 8:9

10

I've a mixed array like this one (mobile numbers and entities): $targets = array(); $targets[] = '+32647651212'; $targets[] = new Customer(); In my Twig template i have to call getMobile() if t...
Shipper asked 28/5, 2012 at 17:2

4

Solved

Is it possible to directly access an array index from within a Twig template? Here's my setup, using Silex: return $app['twig']->render('template', array('numbers' => array('one', 'two', 't...
Homogenize asked 7/8, 2012 at 10:23

3

Solved

I am implementing an alphabetical search. We display a table of Names. I want to highlight only those alphabets, which have names that begin with the corresponding alphabet. I am stumped with a si...
Prevail asked 25/1, 2012 at 6:58

7

I want to fill a JavaScript array with values from PHP variables using TWIG. <script type="text/javascript"> var cont=new Array(); {% for key, post in posts %} cont[{{ key }}] = "{{ post....
Whitebeam asked 7/5, 2012 at 19:24

3

Solved

I am trying to add pairs of key value to an array with their current values for all those attributes not starting by '_'. For some reason, the merge replaces the value of "key" (i.e slug) with the ...
Mascle asked 16/3, 2013 at 20:54

4

How can I format a string in Twig as follows: For example: img = 05myphoto-Car.jpg I need to remove the numeric prefix and - I am mainly using this to output captions for images based on their ...
Pizor asked 17/4, 2015 at 16:35

3

Solved

I am attempting if use a variable to call a specific macro name. I have a macros file that is being imported {% import 'form-elements.html.twig' as forms %} Now in that file there are all the f...
Polythene asked 4/12, 2012 at 21:37

3

i'm using Symfony 4.2 and i use last WebPack Encore. I have issu because i need to use function from my javascript on my twig template, but this never work. I always have same problem: Uncaug...
Monamonachal asked 14/2, 2019 at 10:33

8

Solved

I've got a parent layout and derived from that child sites. The parent layout has a navigation, each navigation point represents one child site. How do i highlight in the parent layout the curren...
Pagoda asked 29/2, 2012 at 9:4

7

Solved

is there a way to check if twig template exists before calling to render? A try catch block seems not to work, at least in dev environment, and plus, I prefer a check than the cost of an exception....
Varney asked 25/5, 2013 at 16:5

7

I'm having trouble doing something that I think should be relatively simple drupal 8 views. I have a content type called Countries. I would like to display the 3 latest country nodes on my homepag...
Intervene asked 18/10, 2016 at 6:32

12

Solved

One of my fields in one of my entities is a "datetime" variable. How can I convert this field into a string to render in a browser? Here is a code snippet: {% for game in games %} ... <td&g...
Hardandfast asked 29/11, 2011 at 22:54

2

I have an issue with my script on pdfjs. i try a first time and i have this message : Deprecated API usage: No "GlobalWorkerOptions.workerSrc" specified. uncaught exception: undefined so ...
Stob asked 20/5, 2020 at 19:38

6

Solved

I've searched a lot on the net how to access the global $_SESSION array from TWIG template and found this: {{app.session.get('index')}}, but when I'm calling it, it returns an empty string. I have ...
Honestly asked 6/12, 2011 at 11:46

© 2022 - 2024 — McMap. All rights reserved.