如何查看CakePHP插件视图 [英] How to view a CakePHP plugin view

查看:92
本文介绍了如何查看CakePHP插件视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在浏览文档和进行搜索,但没有关于如何使用网络浏览器访问插件视图的清楚解释。

I've been going around and around reading the docs and doing searches, but there isn't a clear explanation of how to reach a plugin view using a web browser.

我的插件称为MediaManager。

My plugin is called MediaManager.

我在中添加了CakePlugin :: loadAll(); c $ c> bootstrap.php 文件。

I have CakePlugin::loadAll(); in my bootstrap.php file.

我有 CakePlugin :: routes(); routes.php 文件中。

我有 MediaManagerAppController.php MediaManagerAppModel.php ,我有一个 MediaController.php 文件扩展 MediaManagerAppController 管理器功能的定义。在视图文件夹中,我有一个视图文件 manager.ctp

I have MediaManagerAppController.php and MediaManagerAppModel.php in their respective folders, and I have a MediaController.php file with a MediaManager class that extends MediaManagerAppController, and a manager function defined within. In the view folder, I have a view file called manager.ctp.

我输入URL / MediaManager / Media / manager 进入地址栏,我收到一个错误,我没有在我的应用程序/控制器/目录中创建一个MediaManagerController,所以显然它甚至没有尝试访问我的插件目录。

I enter the URL /MediaManager/Media/manager into the address bar and I recieve an error that I haven't created a MediaManagerController in my app/Controllers/ directory, so obviously it isn't even trying to access my plugins directory.

我通过复制输出 $ this-> Html-> url(array('plugin'=>'MediaManager','controller'=>'media','action'=>'manager'));

我创建了一个 routes.php 文件 plugin / MediaManager / Config / 目录,并放入 var_dump ,但它从来不会调用。

I've created a routes.php file in my plugin/MediaManager/Config/ directory, and put in a var_dump, but it never gets called either.

请帮助!

谢谢。

推荐答案

您应该遵守在网址中使用snake_case的惯例,因此:

You should stick to the convention to use snake_case in your URLs, thus:

$this->Html->url(array('plugin' => 'media_manager', 'controller' => 'media', 'action' => 'manager'));

这将产生URL

/media_manager/media/manager

即使这两个版本都可以工作。
还要确保在添加插件后(或加载新插件)清除缓存。

Even though both versions might work. Also make sure you clear the cache after adding plugins (or loading new ones).

这篇关于如何查看CakePHP插件视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆