• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Database Driven Config Question

#3
Thanks for the help all.

I load my hooks now like


PHP Code:
$hook['pre_controller'][] = array(
        'class'    => 'Language',
        'function' => 'set',
        'filename' => 'Language.php',
        'filepath' => 'hooks'
); 

$hook
['pre_controller'][] = array(
        'class'    => 'Setting',
        'function' => 'set',
        'filename' => 'Setting.php',
        'filepath' => 'hooks'
); 


And  my language hook

PHP Code:
<?php

class Language {

    public function 
set()
    {
        
$this->CI =& get_instance();

        
$this->CI->load->library('site');

        if (
$this->CI->uri->segment(1) == 'admin')
        {
            
$this->CI->db->where('code'$this->CI->site->get('admin_language'));
            
$query $this->CI->db->get($this->CI->db->dbprefix 'language');

            
$this->CI->config->set_item('admin_language'strtolower($query->row()->name));

            
$this->CI->config->set_item('language'strtolower($query->row()->name));

            
$this->CI->lang->load('admin/general'strtolower($query->row()->name));
        }
    }



And my setting hook

PHP Code:
<?php

class Setting {

    public function 
set()
    {
        
$this->CI =& get_instance();

        
$this->CI->db->where('item''url');
        
$query $this->CI->db->get($this->CI->db->dbprefix 'setting');

        
$this->CI->config->set_item('base_url'$query->row()->value);
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Database Driven Config Question - by salain - 08-17-2017, 04:42 AM
RE: Database Driven Config Question - by wolfgang1983 - 08-19-2017, 04:35 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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