Search code examples
model-view-controllerphalconvolt

Can a view file request data from the database?


This is a general MVC question but the specific framework I am using is PhalconPHP. In this the view files are .volt files - Volt is the template engine used by Phalcon.

Can one of these .volt files request data from the database (e.g. is there a command in Volt to make the request)? We want to allow the admins of the site (logged in) to edit the .volt files themselves in the browser but wanted to first check that Volt does not have any functionality that allows it to get data from the database, e.g. any data accessible in the view file must have been passed by the controller.


Solution

  • Yes, if I remember correctly Volt has access to the dependency injector, including the database connection.

    Also you can embed <?php tags in volt templates.