How to view a CakePHP plugin view

萝らか妹 提交于 2019-12-24 19:28:26

问题


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.

My plugin is called MediaManager.

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

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

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.

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.

I double checked that I was entering the url correctly by copying the output of $this->Html->url(array('plugin' => 'MediaManager', 'controller' => 'media', 'action' => 'manager')); I also tried every combination of upper and lower case letters for the parameters just in case.

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.

Please help!

Thanks.


回答1:


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'));

which will produce the 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).



来源:https://stackoverflow.com/questions/20927965/how-to-view-a-cakephp-plugin-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!