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

Routing problem

Hi,

I'm having a problem with my css and javascript files. If I'm at the root of my app, the css and the JS looks fine and they url looks like that : https://localhost/maestro/js/jquery.min.js

But, if I'm going in another controller it goes like this :

https://localhost/maestro/session/js/jquery.min.js

And all my design is mess-up. Does anyone knows why the controller is added to my css and JS files URL ?

Thank you.

Show you infrx.phtml (volt) template code



31.3k

Hi, here you have it : [code] <!DOCTYPE html> <html class="uk-height-1-1"> <head> <meta charset='utf-8'> <?php echo Phalcon\Tag::getTitle(); ?> <LINK href="css/uikit.almost-flat.min.css" rel="stylesheet" type="text/css"> <LINK href="css/site.css" rel="stylesheet" type="text/css"> </head> <body class="uk-height-1-1"> {{ content() }} <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/uikit.min.js"></script> </body> </html> [/code]

change:

href="css/uikit.almost-flat.min.css" => href="/css/uikit.almost-flat.min.css" 
src="js/jquery.min.js =>  src="/js/jquery.min.js

etc.



31.3k

Hi, this did not fix the problem. Actually, it is worst. I lost all the style.



98.9k

You need to use the absolute url helper:

<LINK href="<?php echo $this->url->getStatic("css/uikit.almost-flat.min.css") ?>" rel="stylesheet" type="text/css">
<LINK href="<?php echo $this->url->getStatic("css/site.css") ?>" rel="stylesheet" type="text/css">


31.3k

Hi, thanks for all your answer. That fix the problem. Thank You !