【问题标题】:phalcon: how pass parameters to partial volt which setTemplateAfterphalcon:如何将参数传递给 setTemplateAfter 的部分电压
【发布时间】:2016-12-14 18:51:32
【问题描述】:

我有一个名为 head 的局部视图,我在索引视图之前渲染了这个局部视图,我从模型中获取了客户端信息,然后我想将此客户端模型传递给 head 局部,但我不能。 这是我的代码:

class IndexController extends ControllerBase
{
public function initialize()
{
    $this->tag->setTitle($this->lang('index')->_('title'));
    $this->view->setTemplateAfter('header');
    $this->view->setTemplateBefore('footer');
}

public function indexAction()
{
    $this->view->t = $this->lang('index');
    $this->view->client = $this->getClient();
}

这是我的基本控制器

class ControllerBase extends Controller
{
public function getClient()
{
    $auth = $this->session->get('auth');
    return Client::findFirst([
        "client_id = :client_id:",
        'bind' => [
            'client_number' => $auth['client_id']
        ]
    ]);
}

如何将此客户端模型传递给 head partial?

【问题讨论】:

  • 首先你在查询中的绑定是不行的。在您将其设置为 :client_id: 的条件下,您将其绑定为 :client_number:。你不是转储$this->view->client看有没有结果吗?之后它应该可以工作了。

标签: php partial-views phalcon partial


【解决方案1】:
{{ partial('<FILE_HERE>', ['test':true] ) }}

【讨论】:

  • 能否请您解释一下您的代码
猜你喜欢
  • 2014-11-03
  • 1970-01-01
  • 1970-01-01
  • 2016-03-02
  • 2011-08-10
  • 1970-01-01
  • 1970-01-01
  • 2016-11-14
  • 1970-01-01
相关资源
最近更新 更多