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

View not rendering the way it supposed to.

I was reading the documentation on Phalcon about Hierarchical Rendering("https://docs.phalcon.io/en/latest/reference/views.html#hierarchical-rendering"). And I can't seem to figure it out. I have the following file setup just like the documentation but the only difference is that i am using volt.

--views
  --vacancy
      --index.volt// action
      --new.volt//action
  --layouts
    --vacancy.volt//controller

And this is my Vacancy controller. It's just an empty controller

class VacancyController extends \Phalcon\Mvc\Controller
{
    public function indexAction()
    {

    }
    public function newAction()
    {

    }
}

Problem When i go to "mysite.com/vacancy" everything seems to be rendering just fine. But when i use the "new" action "mysite.com/vacancy/new" i get the content of the file new.volt but it doesn't render the way i think it's supposed too. If i do "mysite.com/vacancy/index" i get the same problem.

In the chrome console i get this error:

Resource interpreted as Script but transferred with MIME type text/html: Resource interpreted as StyleSheet but transferred with MIME type text/html: Resource interpreted as Image but transferred with MIME type text/html:

If i remove the action "new " it will just renders fine! I hope it's clear enough.



2.5k
Accepted
answer

I resolve it just by putting a / before every file that i was including into the html document..

Example

  <script type="text/javascript" src="/js/main.js"></script>

instead of

  <script type="text/javascript" src="js/main.js"></script>