Limit number of functions in class and URI |
[eluser]DavidHopkins[/eluser]
Hello all. I am trying to make a new class that displays dynamic content depending on the end part of a url. The url i want to use is - http://apply.Mydomain.co.uk/index.php/home/woszJ27 the woszJ27 is the unique part that can change. The problem is my home.php class file thinks that woszJ27 is a function and so trys to load it and i get a 404. Is there a way to change a class so that it knows the second part of the URI is a variable rather than another function ? Many Thanks David
[eluser]CroNiX[/eluser]
Yes, use a route or the _remap() function. By default, CI expects the first segment to be the controller, the 2nd segment to be the method and any other parameters go after. If you want to change the default behavior, you need to use one of the methods I listed. Code: $route['home/(:any)'] = 'home/the_method_to_process/$1'; in controller home.php: Code: class Home extends CI_Controller {
[eluser]InsiteFX[/eluser]
_remap way: Code: // ./application/config/routes.php |
Welcome Guest, Not a member yet? Register Sign In |