Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can you define the css and javascript for all views?

On the first page in the following files index.volt charge

<link href='public/img/tolbar/edit-not-validated32.png' rel='shortcut icon' type="image/png" href="">
<link rel="stylesheet" href="css/foundation.css" />
<script src="public/js/vendor/jquery.js"></script>
<script src="public/js/foundation/foundation.js"></script>
<script src="public/js/foundation/foundation.offcanvas.js"></script>
<script src="public/js/foundation/foundation.alert.js"></script>
<script src="public/js/foundation/foundation.topbar.js"></script>

I have understood that the first file in "app / views / index.volt" functions as header and footer everything there is to schedule all forms pass but after changing the directory I get the following error in the console browser

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/tesis/spm%5contacto/css/foundation.css"

So, How can you define the css and javascript for all views? or use asset in each action in my controllers



33.6k
Accepted
answer
edited Oct '15

You have to use the url helper to generate proper paths for the static resources:

<script src="{{ url("js/foundation/foundation.topbar.js") }}"></script>


34.2k

This is just what I needed and think it was so easy. thank you