Welcome Guest, Not a member yet? Register   Sign In
How come you can't use base_url in a config file?
#1

[eluser]dallen33[/eluser]
Just curious. I wanted to do something like:
Code:
$config['assets'] = base_url().'assets/';
Is there another way of doing this?
#2

[eluser]InsiteFX[/eluser]
Create an assets_helper.php

Here is a start:
Code:
if ( ! function_exists('asset_url'))
{  
    function asset_url()
    {
        // the helper function doesn't have access to $this, so we need to get a reference to the
        // CodeIgniter instance.  We'll store that reference as $CI and use it instead of $this
        $CI =& get_instance();
      
        // return the asset_url
        return base_url() . $CI->config->item('asset_path');
    }
}

if ( ! function_exists('css_url'))
{  
    function css_url()
    {
        // the helper function doesn't have access to $this, so we need to get a reference to the
        // CodeIgniter instance.  We'll store that reference as $CI and use it instead of $this
        $CI =& get_instance();
      
        // return the asset_url
        return base_url() . $CI->config->item('css_path');
    }
}

if ( ! function_exists('js_url'))
{  
    function js_url()
    {
        // the helper function doesn't have access to $this, so we need to get a reference to the
        // CodeIgniter instance.  We'll store that reference as $CI and use it instead of $this
        $CI =& get_instance();
      
        // return the asset_url
        return base_url() . $CI->config->item('js_path');
    }
}

Now set your paths in a config file...
Code:
$config['asset_path'] = 'assets/';
$config['css_path']   = 'assets/css/';
$config['js_path']    = 'assets/js/';





Theme © iAndrew 2016 - Forum software by © MyBB