duanbiao4035 2016-11-25 16:15
浏览 41

如何在CakePHP中的插件中呈现正确的视图?

This is my controller method that I am trying to call and I have edited the routes.php so that it calls it and it finds it.

    /**
 * Add method
 * //TODO You can set the company and it works as it is supposed to, but when you have an error regarding the editions not set, you just need to return. This needs to be done later on.
 * @return \Cake\Network\Response|void Redirects on successful add, renders view otherwise.
 */
public function add()
{
    parent::_add();
    $this->set('columns', [
        'title' => ['title' => __d('cockpit', 'Companies'), 'label' => 'Company']
    ]);

    $this->set("dataAddUrl", '/customerBehaviors/add');
}

I have a problem with rendering the view. enter image description here

When I put inside this method $this->render('add.ctp'); then it renders the right view, in any other case it just doesn't. In the error itself it doesn't say it goes to the right route. Which is this /srv/www/cemcloud2/plugins/Cloud/src/Template/CustomerBehaviors/add.ctp I don't know how to add this so that it goes directly there. I want to achieve this without rendering the view using $this->render('add');

We are using both plugins and src directories and in our source directory is the one that I want to inherit from my view. (I believe last sentence doesn't make much relevance to the issue itself). Could someone tell me what am I doing wrong ?

  • 写回答

1条回答 默认 最新

  • douyou2368 2016-11-26 11:22
    关注

    I have found the solution to my question. Because as stated in the comments to my own question, I have had a problem with cakephp inside Vendor. I have deleted the vendor directory and then have once again do composer install, which solved the problem.

    评论

报告相同问题?

悬赏问题

  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单