我正在尝试为已选择任意数量的可用“模块”的用户加载一组“模块”的视图。我可以获取模块的名称或数据库中的任何列。使用CodeIgniter将“模块”数据加载到视图中根据每个用户的动态使用CodeIgniter
load->view($name . '_view');
我似乎无法想出一个方法来加载基于'模块'名称的视图的数据,虽然。
//Loads the rows (selected modules) I need for this user into an array
$modules['modulearr'] = $this->module_model->getModuleUser();
for($i = 0; $i < count($modules['modulearr']); $i++){
//Get the variable from the array
$name = $modules['modulearr'][$i]->mod_name;
//The below works.
$this->load->view($name.'_view');
//The below would not work. (this is the crux of my problem)
$data = $this->$name.'_model'->get();
$this->load->view($name.'_view', $data);
}
还拥有基于这样的事实,我不能改变$this->load->THIS_PART
动态加载控制器模型的问题。
我对一切都陌生,所以可能有一个基本的概念,我不抓住。如果你能指出我正确的方向;那将是真棒。我可以做一大堆if语句,但看起来很混乱。当然有更好的方法。提前致谢!
啊,我的坏,我错过了这个问题,它仍然产生一个串联字符串的解析错误。 – Allansideas 2009-06-15 10:51:03