0

を介して結果変数を提供するコントローラーからのアクションがあります$this->set('found_products', $data);。ビュー ページproducts.ctpは 2 つのセクションに分かれています。

  1. その上に、ユーザーが検索する文字列を入力するフォームが$found_productsビューに設定されています。

  2. その下に、 が設定されている場合にのみ表示されるページ分割された結果$found_products。すなわちif (isset($found_products))真です。

が true の場合if (isset($found_products))、フォームの下に最初のページが表示され、検索文字列が既にテキスト ボックスに入力されています。この URL はmyapp/controller/products.

次のページに移動すると問題が発生します。URL がなりmyapp/controller/action/products:2、その下で使用される変数はmyapp/controller/products存在しません。新しいページに移動すると、すべての変数がクリアされるように見えます。以下は、ページングに使用しているコードです。このために書かれた再ルーティング ルールはありません。この問題を解決するにはどうすればよいですか?

        <div class="paging">
            <?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
            <?php echo $this->Paginator->numbers();?>        
            <?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
        </div>

アクション ( ) で $_SESSION を使用し、これをビューに設定して、この問題を回避しようとしましたが、これを実行するproductsと、「$this->Paginator」が機能しなくなりました。

4

1 に答える 1

1

$this->Paginator->options を使用して、渡された引数をページネーション リンクで保持できます。このコードを試してください

<div class="paging">
    <?php $this->Paginator->options(array('url' => $this->passedArgs)); ?>
    <?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
    <?php echo $this->Paginator->numbers();?>        
    <?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
</div>
于 2012-04-21T06:02:45.010 に答える