从开始,让我们专注于订单控制器.
所以我的订单由许多子视图组成.例如,详细信息,历史记录,地址,附件,笔记等.我把它们放在一个jQuery标签界面上.
我们来看一些代码
layout.PHP中
<div class="page-content"> <div class="row"> <div class="col-md-12"> <ul class="nav nav-tabs responsive hidden-xs hidden-sm"> <li class="<?PHP echo ($activeTabSub === "1") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">Master details</a> </li> <li class="<?PHP echo ($activeTabSub === "2") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">History</a> </li> <li class="<?PHP echo ($activeTabSub === "wyk") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">Address</a> </li> <li class="<?PHP echo ($activeTabSub === "3") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">Files</a> </li> <li class="<?PHP echo ($activeTabSub === "4") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">Notes</a> </li> <li class="<?PHP echo ($activeTabSub === "7") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">ETC</a> </li> <li class="<?PHP echo ($activeTabSub === "8") ? "active" : ""; ?>"> <a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">ETC</a> </li> <li class="<?PHP echo ($activeTabSub === "9") ? "active" : ""; ?>"><a href="<?PHP echo base_url();?>x/y/<?PHP echo $zgl; ?>">ETC</a> </li> </ul> </div> </div> <?PHP $this->load->view($widget,$activeTabSub); ?> <?PHP $this->load->view($main_content,$activeTabSub); ?> </div>
在我的示例中,$widget视图是一个子视图,它是一个带有工具的窗口小部件,例如每个单独的activeTabSub的不同编辑/添加按钮. $main_content是每个人的html视图.
现在为控制器[订购]
public function functiontolink1() { $data['main_content'] = 'x/y'; $data['widget'] = 'x/widget'; $data['heading'] = ""; $data['activeTab'] = 'pzlec'; $data['activeTabSub'] = '2'; $data['strona'] = 'text'; $data['dzial'] = 'text'; $seg= $this->uri->segment(3); $data['zgl'] = $seg; if(isset($seg)){ $data['pracownicy'] = $this->Zlecenia_model->pracownicy($zgloszenie); switch($this->userGroup){ case 1 : $data['main_content'] = 'x/y'; break; case 2 : $data['main_content'] = 'x/y'; break; case 3 : $data['widget'] = 'Client/x/widget'; $data['main_content'] = 'Client/x/y'; break; default: show_404(); break; } $this->load->view('Client/x/layout',$data); }else{ show_404(); } } public function functiontolink2() { $data['widget'] = 'x/widget'; $data['heading'] = ""; $data['activeTab'] = 'pzlec'; $data['activeTabSub'] = '2'; $data['strona'] = 'text'; $data['dzial'] = 'text'; $seg= $this->uri->segment(3); if(isset($seg)){ $data['zgl'] = $seg; $data['json'] = $this->Zlecenia_model->getSingle($zgloszenie); $vvv= json_decode($data['json']); $data['client'] = $this->Order_model->getclient($vvv[0]->klient); switch($this->userGroup){ case 1 : $data['main_content'] = 'x/y'; break; case 2 : $data['main_content'] = 'x/y'; break; case 3 : $data['widget'] = 'Client/x/widget'; $data['main_content'] = 'Client/x/y'; break; default: show_404(); break; } $this->load->view('Client/x/layout',$data); $this->load->view('zgloszenie/layout',$data); }else{ show_404(); } }
你可以想像,我有9个这样的视图功能的每个链接.当我想要获得一些数据时,问题就开始了,即这9个子视图中的客户端数据 – 只有一个不是每个页面都打了[tab].我不太确定我的设计尝试是否完美.你有一些建议吗?