<script type="text/javascript">var name="value";</script>
I need it to be executed before another file included by use_javascript('name.js');
How to do it in symfony?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do it any number of ways
let’s say, in your action method, you add a template variable like so
Then, in your template file(s)
or
EDIT
Ok, based on your specific needs, you’ll need to do a few things. First, look at your page template (the one located in
apps/app-name/templates– you should see a line that looks like thisThat’s the function that takes all javascript resources defined in
view.ymlfiles or those included by theuse_javascript()helper and prints them to the page.So our goal, then, is to put a javascript block in front of where all the other scripts are included (and by in-front, I mean appearing first in source-order)
To solve this in a somewhat flexible manner, let’s use a slot. Modify the above line in your page template to look like this
Then, in your action method
You could extend this idea by using component slots if you wanted to.