这是我的控制器功能:
function MarketingTaskmanagement(){
/*..................................Mariya : Listing of Added Tasks , Pending Tasks and Finshed Tasks..................................*/
$usrname = $this->Session->read('UserName');
$emp_id = $this->Session->read('emp_id');
$user_level = $emp_id; //The User Level of the Loged User........
/*...................................The Tasks selects here which are Assigned to this user............................................*/
$this->set('user_level', $user_level);
$this->paginate = array('conditions' => array('status = 0', 'assigned_to = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data1 = $this->paginate('TravancoMarketing');
$this->set('list_1', $data1);
/*...................................................END..............................................................................*/
/*................................The Tasks selects here which are Added by this user(Pending Tasks)..................................*/
$this->paginate = array('conditions' => array('status = 2', 'user_id = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data2 = $this->paginate('TravancoMarketing');
$this->set('list_2', $data2);
/*$this->set('list_2', '');*/
/*...................................................END..............................................................................*/
/*...................................The Tasks selects here which are Added by this user..............................................*/
$this->paginate = array('conditions' => array('status = 0', 'user_id = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data3 = $this->paginate('TravancoMarketing');
$this->set('list_3', $data3);/*$this->set('list_3', '');*/
/*...................................................END..............................................................................*/
/*...................................The Tasks selects here which are Added by this user..............................................*/
$this->paginate = array('conditions' => array('status = 1', 'user_id = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data4 = $this->paginate('TravancoMarketing');
$this->set('list_4', $data4);/*$this->set('list_3', '');*/
/*...................................................END..............................................................................*/
$this->render('Marketing/taskmanagement');
}
这是我的观点页面:
<?php echo $this->Html->script('jquery.min.js');?>
<?php echo $this->Html->script('popup.js');?>
<?php echo $this->Html->css('forms'); ?>
<script type="text/javascript">
function go_add_tasks(){
//alert(1);
window.location = "http://localhost/works/cakephp/Travanco/TravancoMarketing/MarketingAddtask"
}
</script>
<div class="marketingcls">
<div class="slabdiv">
<div class="market-head">
<h2 align="center">Welcome To Task Management</h2>
</div>
<? echo $this->element("marketinghead"); ?>
<div style="width:1125px; height:auto; border:0px solid #999999; float:left; margin:50px;">
<?php
//$user_level = 2;
if($user_level != 1){
?>
<table width="100%" style="border:1px solid;" cellpadding="0" cellspacing="0">
<tr>
<th scope="col" align="left">Assigned Tasks...</th>
</tr>
<?php
/*...................................The Tasks selects here which are Assigned to this user............................................*/
if($list_1){
$i=0;
foreach($list_1 as $row1){
$assigned_id = $row1['TravancoMarketing']['id'];
?>
<tr>
<td>
<?php echo $row1['TravancoMarketing']['title'];?>
<input type="hidden" name="assigned_task_id" id="assigned_task_id_<?php echo $i;?>" value="<?php echo $row1['TravancoMarketing']['id'];?>" />
<?php echo $this->Html->link('...View More', '/TravancoMarketing/MarketingAssignedtask/'.$assigned_id, array('class'=>'textlinkclass', 'target'=>'_self')); ?>
</td>
</tr>
<?php
}
}
?>
<tr>
<td>
<?php echo $this->paginator->numbers(); ?>
</td>
</tr>
</table>
<?php
}
?>
<br />
<?php //print_r($list);?>
<table cellpadding="0" cellspacing="0" border="1" width="100%">
<tr>
<th width="34%">Set Task
<input type="button" name="btnaddtask" id="btnaddtask" style="width:70px; height:30px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; float:right; margin-right:30px; cursor:pointer; " value="Add Task" onclick="return go_add_tasks();" />
<!--<input type="button" name="btnaddtask" id="btnaddtask" style="width:70px; height:30px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:normal; float:right; margin-right:30px; cursor:pointer; " value="Add Task" onclick="return pop_add_task_frm_other();" />--> </th>
<th width="35%">Review Task</th>
<th width="31%">Finished Task</th>
</tr>
<tr>
<td>
<table border="1" style="width:100%;" cellpadding="0" cellspacing="0">
<?php
/*...................................The Tasks selects here which are Added by this user..............................................*/
if($list_3){
$i=0;
foreach($list_3 as $row3){
$added_id = $row3['TravancoMarketing']['id'];
?>
<tr>
<td><?php echo $row3['TravancoMarketing']['title'];?>
<input type="hidden" name="set_task_id" id="set_task_id_<?php echo $i;?>" value="<?php echo $row3['TravancoMarketing']['id'];?>" />
<?php echo $this->Html->link('...View More', '/TravancoMarketing/MarketingListaddedtask/'.$added_id, array('class'=>'textlinkclass', 'target'=>'_self')); ?>
</td>
</tr>
<?php
$i++;
} ?>
<tr>
<?php echo $this->paginator->numbers(); ?>
</td>
</tr>
<?php } ?>
</table>
</td>
<td>
<table border="1" style="width:100%;" cellpadding="0" cellspacing="0">
<?php
/*................................The Tasks selects here which are Added by this user(Pending Tasks)..................................*/
$i=0;
if($list_2){
foreach($list_2 as $row2){
$review_id = $row2['TravancoMarketing']['id'];
?>
<tr>
<td><?php echo $row2['TravancoMarketing']['title'];?>
<input type="hidden" name="review_task_id" id="review_task_id_<?php echo $i;?>" value="<?php echo $row2['TravancoMarketing']['id'];?>" />
<?php echo $this->Html->link('...View More', '/TravancoMarketing/MarketingListpendingtask/'.$review_id, array('class'=>'textlinkclass', 'target'=>'_self')); ?>
</td>
</tr>
<?php
$i++;
} ?>
<tr>
<td>
<?php echo $this->paginator->numbers(); ?>
</td>
</tr>
<?php } ?>
</table>
</td>
<td>
<table border="1" style="width:100%;" cellpadding="0" cellspacing="0">
<?php
/*...............................The Tasks selects here which are Added by this user(Finished Tasks).................................*/
$i=0;
if($list_4){
foreach($list_4 as $row4){
$review_id = $row4['TravancoMarketing']['id'];
?>
<tr>
<td><?php echo $row4['TravancoMarketing']['title'];?>
<input type="hidden" name="review_task_id" id="review_task_id_<?php echo $i;?>" value="<?php echo $row4['TravancoMarketing']['id'];?>" />
<?php echo $this->Html->link('...View More', '/TravancoMarketing/MarketingListfinishedtask/'.$review_id, array('class'=>'textlinkclass', 'target'=>'_self')); ?>
</td>
</tr>
<?php
$i++;
} ?>
<tr>
<td>
<?php echo $this->paginator->numbers(); ?>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
没有显示分页链接。这是屏幕截图。
但是当我在控制器中命令代码时:
`/*...................................The Tasks selects here which are Added by this user..............................................*/
$this->paginate = array('conditions' => array('status = 1', 'user_id = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data4 = $this->paginate('TravancoMarketing');
$this->set('list_4', $data4);/*$this->set('list_3', '');*/
/*...................................................END..............................................................................*/
/*...................................The Tasks selects here which are Added by this user..............................................*/
$this->paginate = array('conditions' => array('status = 0', 'user_id = '.$user_level), 'limit' => 3, 'order' => array('TravancoMarketing.id' => 'DESC' ) );
$data3 = $this->paginate('TravancoMarketing');
$this->set('list_3', $data3);/*$this->set('list_3', '');*/
/*...................................................END..............................................................................*/`
$this->render('Marketing/taskmanagement');
Then it will displays pagination in all section ,but that pagination not correct ,that means the pagination count is correct only for first section in this time..
这是追逐代码顺序后的截图: 那么我的代码中的问题是什么......
The pagination is not working correctly in my view page.
It take the pagination links of last executed query and put this link for all section .This is the main problem in my code.
How can i solve this?
答案 0 :(得分:0)
不幸的是我认为在技术上使用内置分页在单个页面上对多个模型进行分页是不可能的,因为CakePHP无法真正知道要分页的特定模型作为分页器助手的所有链接以/controller/action/page:1
的形式出现 - 而CakePHP无法知道page1
与哪种模型有关。
我个人建议采用ajax方法。