0

これは私のコントローラ機能です:

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?
4

1 に答える 1

0

残念ながら、組み込みのページネーションを使用して 1 つのページに複数のモデルをページ付けすることは技術的に不可能だと思います。 -の形式で/controller/action/page:1あり、CakePHP はどのモデルpage1が関連しているかを知る方法がありません。

個人的には ajax アプローチをお勧めします。

于 2012-09-17T08:12:57.703 に答える