Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Accessing namespace models in volt

Hi, I have all my models with namespace MyApp\Models My question is how to directly access the model directly from volt?

For example I have a model of foo in Foo.php:

namespace MyApp\Models;
class Foo extends \Phalcon\Mvc\Model 

I want to retrive all record in Foo in my bar.volt like

{% for x in MyApp\Models\Foo.find() %}
    Name: {{}}<br>
{% endfor %}

But it will generate error. Pls Help.


Calling static functions in volt is still not supported, we hope support it soon, from now you can use php there:

<?php foreach (MyApp\Models\Foo::find() as $x) { ?>
Name: {{}}<br>
<?php } ?>

That's worked great. Volt is awesome :) Thanks Phalcon.


very good, in volt template ,can use php tag?