• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routes with DB Info

#1
[eluser]co[dezyne][/eluser]
I have been scouring around trying to find some information on what I'm attempting to do, and found only this article offering relative answers - problem is, it's from 2008.

Here's hoping there has been some sort of update on this topic.

My controller 'squad' manages all the functionality of an internal group within the larger community of the CMS. I would like to offer admin the ability to change the verb that refers to this group. Examples of such could be: 'team', 'wing', 'platoon', or even 'dogfood' if it satisfies them.

The problem duely noted in the above thread is the issue I have in needing to rewrite the controller name in the URI: Needing to pull the routing from a database string so site.com/squad becomes the value the administrator sets.

I have been researching this for a few hours now and have even attempted to write an extension of the router, but only got this far:
Code:
class MY_Router extends CI_Router {

  function MY_Router()
    {
        $this->config =& get_config();
        parent::__construct();
    }

}

Browsing the web, I have found many functions inside this custom router, but they appear to be far too broad of use than what I'd simply like to accomplish:
Code:
define('UNIT', $this->get_setting('squad-verb') );
$route[UNIT] = "squad";

Does anybody have any suggestions to an approach?

#2
[eluser]co[dezyne][/eluser]
Friend of mine found this article and the solution works perfectly. Granted it takes another db request, but that's the price to pay.

config/routes.php
Code:
require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->where('setting_slug', 'squad-term')->get( '_settings' );
$result = $query->result();
$term = lcfirst($result[0]->setting_value);

$route[$term] = "squad";
$route[$term . 's'] = "squads";

#3
[eluser]Unknown[/eluser]
Hi all, does anybody experience problems with the latest 3.0 develop branch with this technique?

I'm now getting Fatal error: Class 'CI_Controller' not found in system\core\CodeIgniter.php on line 229.

Any help appreciated.
Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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