Domanda

I am working with CakePHP. I want to create subfolder for admin in controller folder for all admin controllers. I have tried Prefix Routing method for this, but it dint work for folders.

I have tried using this: https://github.com/ichikaway/AutoAppBuild, it worked but only for the controller which i have mentioned in routes file.

I want to do something like this:

http://my_site.com/ -----> for frontend

http://my_site.com/admin -----> for admin .

I created a subdirectory under "controllers" dir and added following line to routes.php

$Route->connect('/admin/*', array('controller' => 'admin/dashboard', 'action' => 'display'));

Of course, it doesn't work. Cakephp is confused about the directory and class name.

Can anyone please help me out?

Thanks.

È stato utile?

Soluzione

its wrong method to create admin panel. follow below setup to setup admin.

1) go to core.php and uncomment following code

//Configure::write('Routing.prefixes', array('admin'));

2) now if you want to create login form for admin go to ur users controller and create one method which name start with 'admin_' for example admin_index

3) now open your routes.php and write following code

Router::connect('/admin', array('controller' => 'users', 'action' => 'index', 'admin'=>'true'));

now when you write http://www.example.com/admin it will go to users and admin_index method

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top