问题
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