|
楼主 |
发表于 2008-2-15 15:34:21
|
显示全部楼层
目录结构如下:
file:///c:/question.jpg
这是从网上DOWN的一个用CI来做的网上招聘系统的例子,我借用来试一下MATCHBOX,modules目录下的zp就是module_name
CONTROLLER里的代码如下:
class ZhaopinF extends Controller{
function ZhaopinF(){
parent::Controller();
$this->load->module_model("zp","zhaopinM");
$this->load->module_model("zp","zhaopinMoreM");
$this->load->module_model("zp","userM");
$this->load->module_model("zp","zcM");
$this->load->library('xajax');
$this->xajax->registerFunction(array('check_name',$this,'check_name'));
$this->xajax->registerFunction(array('check_birth',$this,'check_birth'));
$this->xajax->registerFunction(array('check_zc',$this,'check_zc'));
$this->xajax->registerFunction(array('check_phone',$this,'check_phone'));
$this->xajax->registerFunction(array('check_school',$this,'check_school'));
$this->xajax->registerFunction(array('check_zy',$this,'check_zy'));
$this->xajax->registerFunction(array('check_year',$this,'check_year'));
$this->xajax->processRequests();
}
function index($start=0){
$conf['per_page']=20;
$conf['total_rows']=$this->zhaopinM->totalRecordsByCondition("where is_show='1'");
$conf['base_url']=site_url()."/zp/zhaopinF/index/";
$conf['uri_segment']=3;
$this->load->library('pagination',$conf);
$temp['links']=$this->pagination->create_links();
$res=$this->zhaopinM->getZpLimitCondition($conf['per_page'],$start,array('is_show'=>'1'));
$temp['res']=$res;
$temp['base_url']=base_url();
$temp['title']="招聘信息页";
$temp['total_rows']=$this->zhaopinM->totalRecordsByCondition("where is_show='1'");
$temp['per_page']=$conf['per_page'];
$this->load->view('zhaopinFV',$temp);
}
function show($id){
var_dump($id); //这里死活输出'show',应该是‘16’
$res_zp=$this->zhaopinM->getZhaopinById($id);
$res=$this->zhaopinMoreM->getZhaopinMoreById($id);
$temp['base_url']=base_url();
$temp['res']=$res;
$temp['title']="更多关于 ".$res_zp->zhiwei;
$this->load->module_view('zp','zhaopinMoreV',$temp);
}
以下是index函数显示的视图,详细信息>>的URL是:http://localhost/index.php/zp/zhaopinF/show/16
file:///c:/question1.jpg
视图部分代码:
<div id="holder">
<div id="content" style="width:800px; margin:auto;">
<table width="100%" class="for_table_f">
<tr style="background-color:#0099FF;">
<td width="43%">招聘职位</td>
<td width="6%">人数</td>
<td width="33%">截止日期</td>
<td width="18%">备注</td>
</tr>
<?php foreach($res as $record): ?>
<tr>
<td><?=$record->zhiwei?></td>
<td style="text-align:center;"><?=$record->p_num?></td>
<td><?=$record->end_date?></td>
<td><?=anchor("zp/zhaopinF/show/".$record->id,"详细信息>>")?></td>
</tr>
<?php endforeach; ?>
</table>
<div id="links" style="text-align:right; padding:5px;">每页 <?=$per_page?> 条记录 共有 <?=$total_rows?> 条记录 <?=$links?></div>
</div>
</div> |
|