can't send parameter to admin function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: can't send parameter to admin function (/showthread.php?tid=545) |
can't send parameter to admin function - valencia - 12-16-2014 hi all, I'am very new with CI, I try to set up CI with Bootstrap themplate, and admin, bootstrap front page works fine and I set up admin page to, but couldn't figure out to change pages in admin theme, I know it's sounds confiused but please try to help me understand this. here is what I have router page PHP Code: $route['(:any)'] = 'pages/view/$1'; and this is my admin_pages class PHP Code: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); and this my pages class PHP Code: if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I'am working on localhost and all my codes is inside the folder codeIgniter now when I write in url Code: http://localhost/codeIgniter/ It's opening the home page,it's ok, fine, and if I change url to this Code: http://localhost/codeIgniter/about this works too. if I want to go to admin page I do this Code: http://localhost/codeIgniter/admin/ this opens the admin page dashboard if I want to change this to tables Code: http://localhost/codeIgniter/admin/tables this give me error "page not found" but if I change in admin_pages method'2 parameter to tables this works. question is why I can't send parameter to my admin_pages method RE: can't send parameter to admin function - Rufnex - 12-16-2014 Can you show your Admin.php Controller. RE: can't send parameter to admin function - valencia - 12-16-2014 Should I have one own controller for admin, do you mean ? My folder looks like this Application Controllers PagesYyyyyyhyyby Admin_pages And in admin_pages I have this to call pages from view I have the code up there under admin_pages. I'm on mobile right now sorry. RE: can't send parameter to admin function - Rufnex - 12-16-2014 Its a good design to have the admin stuff away from the others. So a own admin controller should be. In your example you should have http://localhost/codeIgniter/admin/tables -> /Controllers/Admin.php Right now you have a Admin_pages.php Controller .. right? and with :any you will call a method ... PHP Code: $route['admin/(:any)'] ='admin/admin_pages/$1'; If you go to http://localhost/codeIgniter/admin/tables you call the method tables in your controller. RE: can't send parameter to admin function - valencia - 12-16-2014 I think I understand little bit now, I will try that when I'm at the home. I will be back with result, thank you RE: can't send parameter to admin function - InsiteFX - 12-16-2014 Routes are Controller/Method Also as stated in some of my other posts the (:any) is a catch all route and has to be the last route in your routes.php file. No route will ever run after the $route['(:any)'] PHP Code: $route['default_controller'] = 'pages/view'; RE: can't send parameter to admin function - valencia - 12-16-2014 i just removed this from this PHP Code: $route['(:any)'] = 'pages/view/$1'; to this PHP Code: $route['default_controller'] = 'pages/view'; and in url writing like this Code: base_url and admin/admin_pages/call_admin_pages/tables or charts and this is sending parameters to my method and its works RE: can't send parameter to admin function - valencia - 12-16-2014 #insiteFX Thank You, I did't know it, but I tried still can't send parametre to class admin_pages method to call other pages. my folders looks like this, Code: application/ Where do I make wrong? RE: can't send parameter to admin function - InsiteFX - 12-17-2014 You can always use the CodeIgniter URI Class to get the parameters for the different segments. PHP Code: $this->uri->segment(n) SEE: The CodeIgniter URI Class in the Users Guide. That is what I always use to get different passed in parameters. In your case it would be uri segment (3) |