0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

検索条件(get)を複数ページ持ち越す方法

Last updated at Posted at 2020-09-18

開発中に以下のような遷移時にgetパラメターを持ち越せず苦戦。
①ページ内で検索(get)
②検索結果表示
③検索結果を並び替え(get)
調べてみるとページネーションの際などでも結構はまっている人がいるっぽい。
自分なりに解決した方法が以下。

##③の処理の際にurlのパラメターをhideで投げる。

<input type="hidden" name="condition" :value="setGetParams()">

 setGetParams() {
      return window.location.search
    },

##urldecodeでパラメータと並び替えの条件を合体させurl作成⇒リダイレクト

public function action_result()
  {
    $get = \Input::get();

//urlのパラメターが投げられていたら以下処理
    if(!empty($get['condition'])):
      $url = urldecode(\Uri::current().$get['condition']);
      $url = $url.'&order='.$get['order'];
      \Response::redirect($url);
    endif;

//パラメータが投げられていなければ通常の検索処理
    $data = Model_Data::search($get);
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

多少強引ですが以下で検索条件をページを跨いでも引き継げます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?