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...
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 }} ---> ...
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...
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...
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
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:
<...
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
...
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...
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...
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...
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....
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 ...
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 ...
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...
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...
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 ...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.