I have a cakephp application made by previous employees,
its structure is defined as what can be seen from the following image
I am now stuck at how to figure out what I should do in my current situation in which I am asked to add in another controller, model and view accordingly.
In the views folder there are folders to store different views that match particular controllers and models. I also created one folder and named it as new_foo.
Now you see the app_controller.php ? the file that contains all information available to initialize the menus (navigation bar) that are to call any controllers.
The menu is defined as an array, e.g
menu=array(
array(
'label' => __("Menu Item", true),
'controller' => 'MenuController',
'action' => 'MenuAction'
),
array(
'label' => __("Another item", true),
'controller' => 'AnotherMenusController',
'action' => 'AnotherAction'
));
I also defined one such an element then created myself a new controller class such as
AnotherMenusController.php // please note the plural
class AnotherMenusController extends AppController
{
$this->loadModel('AnotherMenu'); // Please note the plural
function AnotherAction()
{
$this->AnotherMenu->modelFunc();
}
}
And i also created a model class similar to this
class AnotherMenu extends AppModel
{
function modelFunc()
{
print_r("Oh that is it ?");
}
}
However, when I try to run the application in my localhost, I always am reported with an error as
Not Found Error: The requested address ‘/anothermenus/anotheraction’
was not found on this server.
although i could already create a link in the menu item, oh well that seems irrelevant. I am desperate wishing if only there might be someone being able to shed a light on this for me to feel a little better. I am thankful for any help you offered.
Again thank you so much for your concern.
the image is in the following link
https://i.stack.imgur.com/XjQok.jpg
My current problem is that the server doesn’t recognize my controller function, what should I change now ?
I should have missed registering something for it to work out for me in this particular issue.
My first guess would be that your problem is that your local webserver is not respecting the .htaccess. The route the menu is redirecting you to is ‘/anothermenus/anotheraction’ but the webserver reports that such path doesn’t exist. It is possible that the app is configured for production use and your local webserver isn’t configured exactly the same.
Check what happens with other menus and if the paths they link to are similar to the one of the menu you added or not. I would also verify CakePHP’s and the webserver’s logs to verify which one is returning the error. If it is the webserver the webserver’s config (or .htaccess files) are to be reviewed. If it is CakePHP’s, then you need to keep looking at your code (and disregard this answer)