我是Codeigniter的新手,我在将数据加载到页眉和页脚时遇到问题。我在另一个有效的控制器中使用了这个代码,但在发送到页眉或页脚时不起作用。
控制器(尝试):
public function loadSettings() {
$settings = $this->settingmodel->getSetting();
$data = (array) $settings[0];
$this->load->view('header', $data);
}
工作控制器:
public function index() {
if ($this->session->userdata('logdinUser')) {
$sessionArray = $this->session->userdata('logdinUser');
if ($sessionArray['type'] == USERTYPE_PLAYER)
redirect(site_url('player'), 'refresh');
if ($sessionArray['type'] == USERTYPE_PROFESSOR)
redirect(site_url('game'), 'refresh');
if ($sessionArray['type'] == USERTYPE_ADMIN)
redirect(site_url('admin'), 'refresh');
}
$admin = $this->settingmodel->getSetting();
$settings = (array) $admin[0];
$this->load->view('user/index', $settings);
}
所谓模特:
public function saveSetting($array, $id = false) {
$setting['environment'] = $array['environment'];
$setting['analytics'] = $array['analytics'];
$setting['email'] = $array['email_id'];
$setting['paypal_amount'] = $array['paypal_amount'];
$setting['paypal_type'] = $array['paypal_type'];
$setting['paypal_currency'] = $array['paypal_currency'];
$insertedid=$id;
if ($id)
$updated = $this->mongo_db->where('_id', new MongoId($id))->set($setting)->update($this->table_name);
else
$insertedid=$this->mongo_db->insert($this->table_name, $setting);
return $insertedid;
}
function getSetting() {
$query = $this->mongo_db->get($this->table_name);
return $query;
}
在视图中
echo $environment;
答案 0 :(得分:0)
我这样做
我已在layout.php
的{{1}}中创建了常见的root
文件,并加载到该文件的所有内容。我包含view folder
文件和公共{{1}代码到我的布局文件
java script and css
您可以像这样调用表单控制器。
ajax /jquery