Controller names with more than 1 word |
[eluser]GregX999[/eluser]
How do I name controllers (both the file and the class) that have multiple words? And how do I call them in a URL? For example, I have this controller: admin_session.php With a class: AdminSession And trying to call "www.abc.com/admin_session" But that doesn't work. Greg
[eluser]Mirage[/eluser]
Your controller filename and classname must match. Name your controller class 'Admin_Session'. Or name your file AdminSession.php and adjust your url accordingly. If you want the uri and file/class to be different you could use the router to map them. HTH, -m
[eluser]pesho_h_k[/eluser]
But what if you want to have controllers with a dash ... for better indexing? For example - site.com/local-business.
[eluser]pesho_h_k[/eluser]
Yes, I did it with routing, just before I wrote to you here ... but I thought that there could be a direct way. For example, in Zend Framework - if you have a controller/action named with capital letters and not dashes - in the url you'll have only with small letters and dashes. For example: site.com/new-videos/full-list this means that you have a controller named "NewVideosController", and an action there named "fullListAction". And just thought that there could be something like this in CI ![]()
[eluser]Nick_MyShuitings[/eluser]
Zend framework is just imposing its own routing conventions for you on the backend. This is an example of CodeIgniter not babying you and holding your hand through the process. Its the price to pay for the flexibility of the system. If you want even more automagical routing magic you could always go with Drupal or Wordpress (sarcasm).
[eluser]PEN Vannak[/eluser]
Hi, I have the questions similar to this with the new version of CodeIgniter 2.x on the URL routing. Example I have the code in controller like this: Code: <?php And I would like to get the url like this to support with friendly (SEO): Code: http://domain.com/manage-employers Code: http://domain.com/manage-employers/employer-register Code: http://domain.com/manage-employers/employer-activation Code: http://domain.com/manage-employers/employer-login So in routing config, I have to define all of these url above: Code: $route['manage-employers'] = 'manage_employers'; So my question is that is there any good solution that I can define the routing by just change the string from "_" to "-" to support with SEO? Thanks,
[eluser]ivantcholakov[/eluser]
SEO Friendly URLs in CodeIgniter, http://www.einsteinseyes.com/blog/techno...-2-0-hmvc/ Edit: This is a solution for CI 2.x. I am not sure right now, as I remember, such a feature would be built-in CI 3. |
Welcome Guest, Not a member yet? Register Sign In |