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

using many volts in one folder

Hello, i am new in phalcon. I have one templates folder with base.volt that takes some css styles and js. I have a index folder also with index.volt and login.volt when i use {%extends "templates/base.volt"%} in index.volt, i get my css styles perfectly but when i use {%extends "templates/base.volt"%} in login.volt, all my css styles are not working. i have all the actions in indexController. Can anybody help, i am stack. Thank you in advance

any other volt file not getting css styles except the index ones in all my view folders.



6.9k

Take a look at this url: https://github.com/phalcon/invo/tree/master/app/views

That shows the structure for the views in the Invo (demo) application. You'll see there's an index.volt in that root folder, if you open it, there's only a few lines of code in there. Primarily things related to the most basic elements. That's what the root template is for. The {{ content() }} call you see will do the including of templates for you.

If you then look in the layouts folder you'll see the next level of hierarchy. Each file in that folder related to a controller and dresses up the page a little more. These templates too have a {{ content() }} call in there, which ends up loading the method specific template. Which lets say for the about controller with index action can be found in about/index.volt.

So in short: /index.volt loads /layouts/[controllername].volt loads /[controllername]/[action].volt. Each load happens by using the content() call.

That's a somewhat crude explanation, but the idea here is that I feel your approach needs adjusting. Extending from a base.volt is a somewhat faulty approach, I think.