We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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: "https://localhost/tesis/spm_contacto/css/foundation.css"

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



34.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>


81.2k

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