10,622 questions
1
vote
1
answer
48
views
Using macros with dynamic name using dot operator does not work
While upgrading twig v1.30 to v3.22.0 i encountered some problem using macros from an external file and calling them by using a variable value as dynamic name.
Given the twig file with the macros:
{# ...
2
votes
1
answer
93
views
Show several markers on a map with Symfony UX Map
I would like to have multiple markers on the same map with Symfony and UX Map!
I've read the documentation but can't find the solution there!
At the moment, I can get all the markers but on different ...
1
vote
1
answer
91
views
Trying to format a DateTime results in a "Unknown "format_datetime"" error
I have a new Symfony 6.4 web application, pretty barebone.
I'm trying to format a date using the Twig format_datetime filter:
{{ post.createdAt ? post.createdAt|format_datetime('c') : '' }}
When ...
2
votes
1
answer
73
views
Overwriting block layout_search_suggest_result_price from search-suggest.html.twig in Shopware has no effect
I am trying to remove the price block layout_search_suggest_result_price from the autosuggest search in Shopware v6.6.10.5.
The FroshDevelopmentHelper shows it as
BLOCK BEGIN ...
-1
votes
3
answers
147
views
Is it possible to add classes to the body tag?
Is it possible to add classes to the <body> tag in Twig?
I'm using a theme based on Twig for WordPress https://github.com/flyntwp/flynt
I realize that many standard classes are added to the <...
0
votes
1
answer
139
views
How best to import scripts on a specific page after global variable declaration with Symfony Asset Mapper? [closed]
I tried the solution for this question, and while it works great if I want my script on every page: How to import jQuery as a global variable with Symfony's AssetMapper?
However, I have dozens of ...
3
votes
2
answers
380
views
LiveComponent isn't updating the LiveProp value
I am trying to use the Symfony UX LiveComponent, firstly I tried to use the first exemple of the documentation:
// ArticleSearch.php
<?php
namespace App\Twig\Components;
use App\Repository\...
0
votes
1
answer
58
views
How to access slim request interface inside controller
How to access Slim ServerRequestInterface in Controller.
Below is my working code
HomeController
<?php
namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\...
0
votes
1
answer
108
views
Load different header based on current URL
I have four domains - domain.com, domain.org, domain.africa and domain.net. All share the same user base from db and some content. Users can register and log in on any website. Works perfectly. The ...
1
vote
1
answer
106
views
Can Twig PHP be extended to support multiple-line code blocks? ( Or a better way to embed custom logic in a PHP app? )
We're looking at allowing a way to embed custom code into a PHP application, and exploring secure/sandboxed ways to do that (e.g. if you've used Apex in Salesforce, or are familiar with ...
0
votes
0
answers
42
views
Get Woocommerce product tags inside twig template for tease product
I've been trying to get a Woocommerce product's tags inside a twig template. I want to search for a specific tag so that I can assign a class on the product grid which is inside the tease product twig ...
0
votes
1
answer
141
views
Get URL to a Sulu page by content id
If I want to create a link to a page in a Sulu twig template, I can use the <sulu-link /> tag, which is fine for most usecases. But sometimes I do not want an anchor tag rendered, but only the ...
0
votes
1
answer
310
views
How to pass parameter from stimulus JS controller back to modal window defined in twig template?
In short: I've got grid of purchases, once I click on any purchase, I see links detail and approve purchase. When I click on 'approve purchase', modal window appears and I should be able to approve ...
0
votes
0
answers
53
views
How can I check the value of a paragraph field in Drupal?
I'm new to Drupal, however I need to do the following:
I have a paragraph named ad_section with 2 fields: field_link (type: Plain Text) and field_video (type: Media->Video)
It's necessary that a ...
-2
votes
2
answers
97
views
Printing on different background colours by the result
The result of what I was expecting is not the desired one..
The output of the table, is messing up because of it.
so... the code is this one:
{% if (log.action) == "update"%}
<td ...
0
votes
1
answer
79
views
Drupal Twig variable initialization error
The problem I'm trying to solve is this: I need a unique (but human readable) class name to be able to style Taxonomy Term page depending on the term shown. I unsuccessfully tried several approaches, ...
0
votes
1
answer
104
views
SULU frontend with twig and react
I'm working on a SULU project that uses Twig for the frontend and has a custom webpack for it. I need to use React for certain components, components that require more interaction, state management, ...
0
votes
1
answer
28
views
How to prevent white-space between {% set %} and {% block %} in twig without messing up indentation?
Say one has this twig template:
{% set first %}
{% block some_block %}
{{- variable -}}
{% endblock %}
{% endset %}
Passing in an empty string, '' in variable, one can see that dumping out ...
0
votes
0
answers
59
views
Force Twig to render a specific cache file
If I ask Twig to render example.twig it will generate a cache file named something like 8e8456gffc99c672976eff.php (if cache is enabled).
Is there a way to then take 8e8456gffc99c672976eff.php, and ...
0
votes
1
answer
114
views
twig error: Unexpected token "punctuation" of value ":" ("end of statement block" expected)
I am attempting to take all of the start dates of my coworkers and calculate a total # of years of experience. However I am getting the following error
Twig\Error\SyntaxError: Unexpected token "...
0
votes
2
answers
76
views
Modifying default theme column_right menu in OpenCart 3.0.4
OpenCart provides more default features than I wish to offer my users. My current challenge is how to remove menu entries such as "Recurring payments" and "Downloads" from the ...
0
votes
1
answer
229
views
How do i set timezones with Symfony translation and the ICU message format?
I'm storing all my dates as UTC in the database. But I want to display them in the users timezone.
$mydate = new \DateTime('2024-08-07 12:00:00');
Displaying the dates in Twig with the date filter ...
0
votes
0
answers
107
views
How to translate the automatic Symfony FileType input placeholders or labels?
I'm trying to translate the automatic placeholders or labels for a Symfony FileType.
Specifically, I want to change the text "Escolher ficheiro" e "nenhum ficheiro selecionado" to ...
0
votes
1
answer
29
views
Symfony 6 search form not working. The end template is not shown
In a search form, the search result cannot be displayed nor are there errors. It automatically returns to the search form and does not go to the Twig page chosen as the destination. Here the code:
#[...
0
votes
1
answer
347
views
How to apply a specific class in Twig based on the classes of an element?
I'm working on a Drupal website and trying to apply specific classes in Twig files based on the existing classes of an HTML element. Specifically, I want to apply the 'Card-label' class to the title ...