How to load a view based on condition in Controller (Codeigniter)

后端 未结 3 1097
天涯浪人
天涯浪人 2021-01-21 09:11

I\'m new to codeigniter. I\'m trying to make a simple site, that will get its \"settings\" on the database, if the site is enabled (1) or not (0).

I\'m trying to determi

3条回答
  •  一生所求
    2021-01-21 09:46

    Use something like this for your controller:

    $setting = $this->modelName->getsetting();
    
    if($setting['maintenance'] == 1){
    
        $this->load->view('maintenance', $data);
    
    } else {
    
         $this->load->view('index' $data);
    
    }
    

    Be sure to replace 'modelName' with the name of the 'getsetting' method's model.

提交回复
热议问题