We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

如何在volt中使用模型(How to use the model in volt)


我建议您 Google,这应该不是什么高难度的操作。


A model object or results you could assign using $this->view->setVar("modelresult", $modelObjectOrObjects); Then the variable is accessible in volt for loops for example. But you wouldn't like to do in volt something like this Modelclass::findFirst()... even if it was possible because this is to be done in the controller. Am i right?


Maybe it will be helful. https://docs.phalcon.io/en/latest/reference/volt.html#for

{% for robot in robots %} <li>{{ robot.name|e }}</li> {% endfor %}

现在在学习,先放弃VOLT模板学习其他的技术, 模板这块主要是各种生成组件。 优势也好也不好。