Doctrine connection in Twig extension - Symfony

Twig
According to what I've read online, it should be possible to create Doctrine connection inside Twig extensions file. I'd like to create an extension w...
4 months ago

Twig template - Loop iteration sum items in loop

Twig
{% for product in products %} {% set totalPrice = (product.quantity * product.price)|number_format(2, '.', ',') %} {% endfor %} {{ totalPrice }}...
4 months ago

Symfony/Twig: internal ID for form widgets?

Twig
I've to modify the radio_widget and would like to give the <label> and <input> the same ID, which should be unique for each pair. Current...
4 months ago

Can I put html inside a Symfony form button with Twig?

Twig
I'm trying to put html inside a form button with twig like: {{ form_widget(form.jiraStatus, { 'label': '<i class="fa fa-bug"></i>...
4 months ago

In Pico CMS content markdown file how to define an array

Twig
In my simple Pico (0.9) based website I would like to add category pages that would list a set of objects, different for each category and defined in ...
4 months ago

Symfony dynamic wildcards in google maps infowindow

Twig
I have a small application in Symfony3 with a google map showing some locations injected from the database. What I am trying to achieve is to place a ...
4 months ago

Check if template exists before rendering

Twig
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, ...
4 months ago

How to render twig templates into a service. Is it Best practice?

Twig
I have the following Symfony 3 controller: public function register(Request $request) { $username=$request->get('username'); $password=...
4 months ago

Variable as name of row in TWIG : Symfony 2

Twig
I have a problem in my Symfony2 application. In Controller I'm getting an array of facebook users and posting it to my form class, where I create some...
4 months ago

Parsing current uri to get the current route params inside a partial. How to avoid?

Twig
Inside the base.twig layout I render the toc: {% block sidebar %} {{ render(url('toc_documents_categories')) }} {% endblock %} The matchi...
3 months ago

Twig block USE in IF block

Twig
I render same page in modal and self. I wonder if there is some way to check for some condition and if condition is true not to include header and fo...
3 months ago

Get the right value out of the right array-entry in MongoDB / Twig

Twig
I'm trying to get a value from an array inside a mongodb collection. My db entries look like: _id : "somerandomid" page : "page1" entries : [ { ...
3 months ago

Symfony2 - execute TWIG inside JS events

Twig
I saw many examples assigning twig to JS variables in <script> tag, so I decided to call twig function inside click event, but unfortunatelly, c...
3 months ago

Twig interpolate variable into translated string

Twig
I have a Sylius instance with translations file configured and properly working Right now just using a snippet like this in my twig: {{ 'project.syl...
3 months ago

what is if not and ct.viewless|default(false) in twig?

Twig
I just came across the following syntax in the bolt CMS : {% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) %} Now the ...
3 months ago

Symfony/Twig: Stop rendering the rest of a template

Twig
I've been searching the internet for this, but I can't find anything regarding this. I'm creating a simple twig template that is going to be used on ...
3 months ago

access loop.index when within another loop in twig

Twig
How can i access the loop's index when i'm in a second loop? like this: {% for i in range(0, 3) %} {% for j in range(0, 9) %} ...
3 months ago

how to use split twig template field content type in drupal 8?

Twig
I need your help to solve the problem with split in twig. I want to separate my var {{label}} in an array, try using {% set array = label | split (...
3 months ago

Symfony: How to render a template as a simple txt

Twig
I have to render a template of an action as a simple .txt file. How can I do this? Is there a way other than using the Response object? Using a Resp...
3 months ago

Twig: prevent parsing of client-side templates

Twig
I need to output a portion of client-side handlebars templates, which has tags similar to twig's 'say' tags: <script type="text/x-handlebars"&gt...
3 months ago