普通网友 2013-06-10 16:26
浏览 40

动态自定义CodeIgniter配置文件

I have created a custom configuration file for my custom CMS I am building using CodeIgniter. I want to have a "Configuration" page in the CMS that allows the user to save a contact email address and other variables.

I want to allow the user to set these config variables on the fly from the admin CP but I am having trouble doing so.

I found this article here: Dynamically updating config data codeigniter which asks a similar question but the answer is not exactly what I was looking for.

Is it possible to update a config file permanently on the fly from a controller? Right now my code looks like this:

     $this->config->load('cms_config');

    //load the initial view
    $this->data['subview'] = 'admin/setup/index';
    $this->load->view('admin/_layout_main', $this->data);

    //validate form
    if($this->form_validation->run('site_config') == TRUE) {

        $this->config->set_item('contact_email', $this->input->post('contact_email'));

    }

but this doesn't seem to update the file at all. In fact, nothing seems to happen upon form submit.

  • 写回答

1条回答 默认 最新

  • doumo3903 2013-06-11 16:46
    关注

    This is one of the design limitations I have encountered while working on my own CMS. configuration being inside the framework files. I then though of using a second database (SQLite for instance) to bootstrap extra configuration data but then faced a second limitation of CI as it doesn't support multiple databases at once. The only remaining option is to hard edit the config files themselves in a different context, a custom files or codeigniter hooks could do the job. or an installation controller (as implemented in pyro CMS)

    If you would like to discuss more cms design issues let me know as I'm working on similar things.

    Good luck.

    评论

报告相同问题?

悬赏问题

  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据