class DefaultController extends Controller { public function indexAction($page, $name) { return $this->render(‘default/new.html.php’ // , array( // $name =&…
Tag: twig
Manually switch _locale in symfony 4
I’m absolutely stuck in getting a solution to manually switch the _locale variable in Symfony 4. I followed these steps, but now I have absolutely no idea how to make a simple switch button in the nav section. I also took a look a this question, but this seems to be an older Symfony version.. Can anyone please help me
How to create a function in twig to calculate the age of a person using Symfony
I have this PHP code that works but I would like to be able to use the same but within twig in symfony. Answer To make this code guide me in this post: https://es.stackoverflow.com/a/73288/6524 The only variant in the file EdadUsuarioExtension.php
Price Alert:How to pass price product from a list of profucts to a popup?
I’m having a list of specific products,foreach product I have a button Create Price Alert.When I click on the button a pop up shows up and contains the price of the current product : <link href="{{…
SVG icon in twig template
I’m struggling with svg icons. I’m creating menu and to do this I have to use several of svg icons. I already know, that if I want to manipulate colour with help CSS (for example when icon is active/hover) I have to use in HTML <svg> tag not <img src=”path-to-icon.svg”/>. How can I solve this problem in a nice way?
Twig accessing protected/private model variables
I have a problem with Twig, (in fact this is not really a problem but it’s disturbing to me) I have a Post model class in php and i have some protected variables (I also tried with private). To acces them I have a public function in php getMyVariable. If in my controller I try to echo the protected variable
Impossible to access an attribute on a string variable
In my controller i just pass some users on my twig view. Here is my function : And this is my twig view where i want to display some information on a html table : And i got this error : Impossible to access an attribute (“name”) on a string variable (” “). for this line : Thanks for help!
Symfony: pass parameter to Ajax url
I am trying to figure out how to enable/disable user with checkbox without page reload. index.html.twig UserController Question How can I set corresponding user id to enabledChange function and change checked state depending on user state? Answer You need to add quotes to your variables, and pass changePath as an argument: then: I hope this will help.
How to render json into a twig in Symfony2
The question is how to pass a json to twig to render a template. I’ve tried to pass a json with JsonResponse object but I did not find the way to render the template. TarifasController.php index.html.twig How can I pass a json from the controller to use it in the DataTable (in twig template) but mantaining the render in this
Pass javascript variable to twig
I just want to pass a javascript variable to a twig path. Now i’m using this, but it doesn’t work. Answer Note You should really look at the FOSJsRoutingBundle.