我是cakephp的新手,并且使用带有bootstrap css的2.4版本。 我几乎完成了我的项目,但在使用分页创建搜索时出现了一些错误。
在Cakephp中分页时,第一页工作正常但最后2-3页显示错误,因为在此服务器上找不到请求的地址。
表格如下。 大学,课程,学期,科目,单元,主题 这些模型分别具有从左到右的多种关系。 例如大学里有很多课程,课程有很多学期......我的搜索操作如下。
public function searchresults() {
if($this->request->is('post')) {
$unid=$this->data['University']['universities'];
$searched = $this->data['University']['searchtxt'];
$this->Session->write('Searched.stext',$searched);
$this->Session->write('Searched.univ',$unid);
}
$unid=$this->Session->read('Searched.univ');
$searched = $this->Session->read('Searched.stext');
//Create Join to find total numbers of records after search
$this->Topic->bindModel(array(
'belongsTo' => array(
'Unit' => array(
'foreignKey' => false,
'type' => 'RIGHT',
'conditions' => array(
'Topic.unit_id = Unit.id' ,
)
),
'Subject' => array(
'foreignKey' => false,
'type' => 'RIGHT',
'conditions' => array(
'Unit.subject_id = Subject.id',
)
),
'Semester' => array(
'foreignKey'=> false,
'type'=>'RIGHT',
'conditions' => array (
'Subject.semester_id = Semester.id'
)
),
'Course' => array(
'foreignKey'=> false,
'type'=>'RIGHT',
'conditions' => array (
'Semester.course_id = Course.id'
)
),
'University' => array(
'foreignKey'=> false,
'type'=>'RIGHT',
'conditions' => array (
'Course.university_id = University.id'
)
)
)
));
$this->Paginator->settings=array(
'limit'=>10,
'page'=>1,
'conditions' => array('or'=>array(
'Topic.name LIKE' => '%'.$searched.'%',
'Topic.description LIKE' => '%'.$searched.'%'
)),
);
$data=$this->paginate('Topic');
//debug($data);
$this->set('searched',$searched);
$this->set('sresults',$data);
$this->set('uni_id',$unid);
}
我的观点的分页部分代码如下:
<div class="row"><!--Pagination links begins -->
<div class="col-sm-8 col-sm-offset-3">
<!-- Shows the next and previous links -->
<ul class="pagination largescreen">
<li class="disabled-page mobileview">
Page <?php echo $this->Paginator->counter(); ?>
</li>
<?php echo $this->Paginator->prev('«', array('tag'=>'li'), null, array('class' => 'disabled-page','tag'=>'li')); ?>
<!-- Shows the page numbers -->
<?php
echo $this->Paginator->numbers(array(
'tag'=>'li',
'separator'=>'',
'currentClass'=>'active',
'currentTag'=>'a',
'modulus'=>4
));
?>
<?php echo $this->Paginator->next('»', array('tag'=>'li'), null, array('class' => 'disabled-page','tag'=>'li')); ?>
</ul>
</div>
<div>
<ul class="pagination pagination-sm smallscreen" style="overflow:auto;">
<li class="disabled-page mobileview">
Page <?php echo $this->Paginator->counter(); ?>
</li>
<?php echo $this->Paginator->prev('«', array('tag'=>'li'), null, array('class' => 'disabled-page','tag'=>'li')); ?>
<!-- Shows the page numbers -->
<?php
echo $this->Paginator->numbers(array(
'tag'=>'li',
'separator'=>'',
'currentClass'=>'active',
'currentTag'=>'a',
'modulus'=>8
));
?>
<?php echo $this->Paginator->next('»', array('tag'=>'li'), null, array('class' => 'disabled-page','tag'=>'li')); ?>
</ul>
</div>
</div><!--Pagination links ends -->
在搜索了很多关于这个问题之后我会被困住,请帮忙...