[英]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. 我试图将所有特定于部署的更改集中到CI的主配置文件中,然后从此处读取“较小”的配置文件(如插件的配置文件)。
In this specific instance: 在这种特定情况下:
I have CKEditor/CKFinder as plugins to my Codeigniter app. 我有CKEditor / CKFinder作为我的Codeigniter应用程序的插件。 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.
我想从CKFinder的配置文件中读取CI的主配置文件中的值,以便可以获取baseURL。
In order to tell CKFinder where to look for images, you need to specify a baseURL in its config.php file. 为了告诉CKFinder在哪里寻找图像,您需要在config.php文件中指定baseURL。 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.
我希望它从我的主配置文件中读取baseURL并将图像目录附加到该目录,而不是直接修改CKFinder的文件。
I tried the following in CKFinder's config.php file to no avail: 我在CKFinder的config.php文件中尝试了以下操作,但无济于事:
$baseUrl=$this->$config['base_url'].'assets/my_images/';
Please lead me to the light! 请把我引向光明!
Mmiz Mmiz
if you wanna read base_url
you can do something like this: 如果您想阅读
base_url
,则可以执行以下操作:
$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');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.