• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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/';



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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