Reputation: 11
I was following tutorial of the phalcon framework and came up with a volt engine and its view page. I was wondering how the content() function work in volt view pages? and I'm also confused with the connection between the pages content? The structure of the code is as follows: - views/index.volt - views/index/index.volt - views/layout/main.volt
The views/index.volt page inside the views is the first page to load at the beginning but how are they interconnected with the pages index/index.volt and layout/main.volt? I've followed the tutorial from the official site of phalcon. http://phalcon-php-framework-documentation.readthedocs.org/en/0.7.0/reference/tutorial-invo.html
Upvotes: 0
Views: 2772
Reputation: 2211
Phalcon has a hierarchical view structure with three levels: Layout, Controller and View.
When it is time to render a page Phalcon starts with the Layout. When Volt comes to a {{content()}}
it renders the next view level down and adds that to the rendered view.
{{content()}}
is an alias in Volt of Phalcon\Mvc\View::getContent()
.
Upvotes: 3
Reputation: 1837
Take a look at the specific View documentation.
The {{ content() }}
is where the output of the next file down in the hierarchy will be placed. I.e. if you had a page file myPage.volt
and a layout file myLayout.volt
then the contents of myPage.volt
would appear where the {{ content() }}
line is inside myLayout.volt
.
Upvotes: 2