Welcome Guest, Not a member yet? Register   Sign In
Retrieve base_url inside custom config file
#1

[eluser]ibnclaudius[/eluser]
How can I retrive base_url inside a custom config file?

I'm trying this but no success:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* 1. FOLDERS
* --------------------------------------------------------------------------------
* ================================================================================
*/

/**
* 1.1 Static
* --------------------------------------------------------------------------------
*/
$config['css'] = $this->config->base_url('static/css');
$config['js'] = $this->config->base_url('static/js');
$config['img'] = $this->config->base_url('static/img');

Quote:Fatal error: Call to a member function base_url() on a non-object in /var/www/money/application/config/meuboletim.php on line 13
#2

[eluser]InsiteFX[/eluser]
Use a help file to do it, config files are loaded at the beginning so you cannot get it that way

Example:
Code:
// config file
$config['asset_path'] = 'assets/';

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');
    }
}

// then
<?php echo asset_url();?>
#3

[eluser]Glazz[/eluser]
I think you can't, i recomend you to create a helper to do this.
#4

[eluser]ibnclaudius[/eluser]
Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB