【问题标题】:Load partials based on action parameter in Phalcon根据 Phalcon 中的动作参数加载部分
【发布时间】:2016-03-18 08:27:29
【问题描述】:

我想根据路由参数在 Phalcon 中加载部分视图。

我有这个动作,它决定了部分的名称:

public function addAction($discipline = null)
{
    if (isset($discipline)) {
        $this->view->partial = 'add' . $discipline . '.phtml';
    } else {
        $this->view->partial = 'addstatic.phtml';
    }
}

在主视图中,我想用 Volt 命令partial 加载这个部分,如下所示:

{{ partial('partials/training/' ~ partial) }}

但我遇到了这个错误:

View 'C:\xampp\htdocs\apneist_social/app/views/partials/training/addstatic.phtml' was not found in the views directory

如果我用目录浏览器浏览到这个文件,我可以找到这个文件。

【问题讨论】:

    标签: php phalcon volt


    【解决方案1】:

    删除扩展名 (.phtml)。喜欢:

    $this->view->partial = 'addstatic';
    

    【讨论】:

    • 哇,这很简单。谢谢! :)
    【解决方案2】:

    等一下,你为什么使用 volt 并想在 addstatic 中使用 phtml ?随处使用伏特:D

    【讨论】:

    • 好吧,我在 .phtml 文件中使用 volt。 :) 你可以告诉 Phalcon 你用哪个结尾来表达你的观点,我认为这没有任何区别。
    • 哦,好吧,那没关系:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多