简体   繁体   中英

Accessing CI's config file from a plugin's config file

I am trying to centralize all deployment specific changes into CI's main config file and then have "lesser" config files (like a plugin's) read it from here.

In this specific instance:

I have CKEditor/CKFinder as plugins to my Codeigniter app. I would like to read values from CI's main config file from CKFinder's config file so that I can get at the baseURL.

In order to tell CKFinder where to look for images, you need to specify a baseURL in its config.php file. I would rather it read the baseURL from my main config file and append an image directory to this instead of modifying CKFinder's file directly.

I tried the following in CKFinder's config.php file to no avail:

$baseUrl=$this->$config['base_url'].'assets/my_images/';

Please lead me to the light!

Mmiz

if you wanna read base_url you can do something like this:

$baseUrl = base_url().'assets/my_images/';

Instead if you wanna reach a config-item, you can do this.

$this->config->item('your_constant'); 

and in the config file something like:

$config['your_constant'] = "your string"; 

您可以使用site_url ,原本是base_url的扩展,但用于相对路径。

$baseUrl = site_url('/assets/my_images');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM