Welcome Guest, Not a member yet? Register   Sign In
Controller names with more than 1 word
#1

[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
#2

[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
#3

[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.
#4

[eluser]BrianJM[/eluser]
[quote author="pesho_h_k" date="1295930942"]But what if you want to have controllers with a dash ... for better indexing?

For example - site.com/local-business.[/quote]

Try using routes.
#5

[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 Wink
#6

[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).
#7

[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
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Manage_employers extends CI_Controller {
function __construct(){
  parent::__construct();
}
public function index(){
  //employer home page here
}

public function employer_register(){
  //employer register here
}

public function employer_activation($email,$code){
  //employer validation account here
}

public function employer_login(){
  //employer login here
}
}

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';
$route['manage-employers/employer-register'] = 'manage_employers/employer_register';
$route['manage-employers/employer-activation'] = 'manage_employers/employer_activation';
$route['manage-employers/employer-login'] = 'manage_employers/employer_login';

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,
#8

[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.




Theme © iAndrew 2016 - Forum software by © MyBB