• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller file and class names...

#1
[eluser]xerobytez[/eluser]
This is an issue with CI that has bugged me for quite some time. So I've written a library named settings that manages my applications settings in the database. Now in my admin panel I'd logically like to have a controller named settings where the user can easily change my apps settings. Due to CI's goofy naming conventions I can't have a library and a controller named settings as it creates a collision due to them having the same class name. In a perfect world it would be great if CI had standardized naming conventions for example, model and helper filenames end with _model and _helper respectively. Why don't controllers? or libraries? Has anyone encountered this issue and come up with a solution? Maybe a modified codeigniter and\or router class in the core?

Thanks for reading

#2
[eluser]Prullenbak[/eluser]
I don't think you're not allowed to name your controller Settings_controller. Afterwards you can change your routes file to map 'settings/whatever' to 'settings_controller/whatever'.

I agree, this is a bit of a hassle, but it should work.

In your specific case, why not call it prefs or admin or whatever?

#3
[eluser]xerobytez[/eluser]
This case was just an example, I've encountered it many times in the past with different scenarios. Excellent idea with the routes though I didn't think of that, I ended up using the code below and all is working well. Thanks for the idea!

Code:
$route['(:any)'] = '$1_controller';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.