Welcome Guest, Not a member yet? Register   Sign In
[Solved] Database Driven Config Question
#3

(This post was last modified: 08-19-2017, 05:28 PM by wolfgang1983.)

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



Theme © iAndrew 2016 - Forum software by © MyBB