変更した表示件数を維持しながら検索結果を表示させたいのですが、上手くいきません。逆も然りです。
良い考え方が思い浮かばないので、アドバイスが頂けたら嬉しいです。
現状は検索結果を表示させた後に表示件数を変更すると表示件数だけが変更されてしまい、検索結果がリセットされてしまう状況になっています。
php
1 Controller 2public function index() { 3 4 $artist = $this->request->query('artist'); 5 $title = $this->request->query('title'); 6 $num = $this->request->query('product num'); 7 $jan = $this->request->query('jan'); 8 9 $limit = $this->request->query('limit'); 10 if (!empty($limit)) { 11 $this->paginate = array( 12 'limit' => $limit, 13 ); 14 } else { 15 $limit = 5; 16 } 17 18 $conditions = []; 19 if (!empty($title)) { 20 $conditions['Disc.product_name LIKE'] = "%" . $title . "%"; 21 } 22 if (!empty($artist)) { 23 $conditions['Disc.artist_name LIKE'] = "%" . $artist . "%"; 24 } 25 if (!empty($num)) { 26 $conditions['Disc.product_num LIKE'] = "%" . $num . "%"; 27 } 28 if (!empty($jan)) { 29 $conditions['Disc.jan LIKE'] = "%" . $jan . "%"; 30 } 31 $this->paginate = array( 32 'conditions' => $conditions, 33 'limit' => $limit, 34 ); 35 $result = $this->paginate('Disc'); 36 37 $this->set('discs', $result); 38 39 }
php
1View 2echo $this->Form->create('Search', array('url' => '/discs/', 'type' => 'get')); 3echo $this->Form->input('artist', array('style' => 'width:300px', 'value' => $this->request->query('artist'))); 4echo $this->Form->input('title', array('style' => 'width:300px', 'value' => $this->request->query('title'))); 5echo $this->Form->input('num', array('style' => 'width:300px', 'value' => $this->request->query('num'))); 6echo $this->Form->input('jan', array('style' => 'width:300px', 'value' => $this->request->query('jan'))); 7echo $this->Form->end('Search'); 8 9echo $this->Form->create('Limit', array('url' => '/discs/', 'type' => 'get')); 10echo $this->Form->input('limit', array( 11 'label' => '表示件数', 12 'type' => 'select', 13 'options' => array( 14 '5' => '5', 15 '10' => '10', 16 '20' => '20', 17 '50' => '50', 18 ), 19 'div' => false, 20 'empty' => '選択してください' 21)); 22echo $this->Form->end('Limit');
タイトル「保持」となっていますが内容は「表示」です。どちらでしょうか。
あなたの回答
tips
プレビュー