0

Are there any libraries or helpers that can allow me to have a class ControllerCommonDashboard which extends CI_Controller but have the file name just be dashboard.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ControllerCommonDashboard extends MX_Controller {
}

At the moment I have to make file name same as the class name.

Not sure how to best use these functions to get what I am after

$this->router->fetch_class();
$this->router->fetch_method();
$this->router->fetch_module();
woot
  • 7,406
  • 2
  • 36
  • 55
  • I don't beleieve there is, But why would you want it shorter? – Patrick Jun 14 '14 at 06:32
  • Looks nicer in the files if just have dashboard.php –  Jun 14 '14 at 07:01
  • 1
    That router class you posted is used to get the current class and method from a URI, not exactly what you want. You can display shorter names on the URI but you can't change the name. You can however instantiate a new instance yourself(I guess), instead of having it auto load, load it up yourself `$this->dashboard = new ControllerCommonDashboard` I never tried it, But it might work – Patrick Jun 14 '14 at 07:07

1 Answers1

0

Short answer: No.

No such library or helper.

Long answer:

Don't try to do such hardcore stuff.

I can provide you some solutions.

Solution 1:

Since the long ugly name is ControllerCommonDashboard, there must be some controllers like ControllerAdminDashboard.

You can create 'admin' and 'common' folder in 'controllers' folder. Then you create '/admin/dashborad.php' and '/admin/dashboard.php' for them. Vist url '/common/dashboard' or '/admin/dashboard' would work for this.

Solution 2:

You think the uri for users is too ugly?

Just route them!

http://ellislab.com/codeigniter/user-guide/general/routing.html

add this in route.php

$route['dashboard'] = "controllercommondashboard";

Then everyone can visit uri with '/dashboard/action' on your site.

Solution 3:

Remove the 'Controller' from 'ControllerCommonDashboard', just 'CommonDashboard' would be much beaitiful and simple for both yourself and visitors who go to your site!

尤川豪
  • 459
  • 5
  • 26