【问题标题】:Cakephp 3 Element file is missingCakephp 3 元素文件丢失
【发布时间】:2020-01-22 15:44:01
【问题描述】:

我的问题是我的 navbar.ctp 元素没有加载,我只从 cakephp 收到错误消息

元素文件“Element/navbar.ctp”丢失。

我在 cakephp 的默认布局中的代码(因为我想要所有“视图”中的导航栏)

<?php
    echo $this->element('navbar');
?>

我的元素在 Layout/Element/navbar.ctp

所以我不明白为什么它说我的元素丢失了。 我有什么遗漏吗? 我希望有人可以帮助我解决这个问题。我没有太多信息,因为它本身并不复杂。

【问题讨论】:

    标签: html cakephp cakephp-3.0


    【解决方案1】:

    我认为您将文件放在错误的文件夹中。

    查看食谱:

    元素位于 src/Template/Element/ 文件夹中,并具有 .ctp 文件扩展名。它们是使用元素方法输出的 观点:

    echo $this->element('helpbox');
    

    来源:https://book.cakephp.org/3/en/views.html#elements

    【讨论】:

    • 完全正确。这个文件的位置是src/Template/Element/navbar.ctp,而不是src/Template/Layout/Element/navbar.ctp
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    • 2021-11-16
    • 1970-01-01
    • 2019-06-16
    • 2021-08-20
    • 2019-02-12
    相关资源
    最近更新 更多