I am trying to write a plugin for CakePHP (CakePHP 2.2.3) called LinkElement which takes makes it possible to get a url and hand back a rendered element. My example uses an Ajax tabs table (if there are better ways to do this please say). I cannot get it to load from a URL.
Example:
localhost/LinkElement/Links/
throws:
Error: LinkElementController could not be found.
Error: Create the class LinkElementController below in file: app\Controller\LinkElementController.php
<?php
class LinkElementController extends AppController { }
My layout is as follows:
/app
/Plugin
/LinkElement
/Controller
LinkElementAppController.php
LinksController.php
/Model
LinkElementAppModel.php
/View
Links/
index.ctp
LinkElementAppController.php
<?php class LinkElementAppController extends AppController { }
LinksController.php
<?php App::uses('LinkElementAppController', 'LinkElement.Controller');
class LinksController extends LinkElementAppController {}
LinkElementAppModel.php
<?php class LinkElementAppModel extends AppModel {}
Links/index.ctp (just a dummy until I can get the URL working)
<h2>Working</h2>
Also routes.php
CakePlugin::routes();
CakePlugin::load(array('LinkElement'));
I realise that this is probably simple, but I cannot see it right now and looking at other answers is not helping.
You shouldn’t ever be using caps in URLs. 🙂
The Cake way to access controllers in plugins is to use underscore notation:
/plugin_name/controller_name/actionSo in your case:
localhost/link_element/links/<action>ref: http://book.cakephp.org/2.0/en/plugins.html#plugin-tips