1

このようなルートを作成しました

Router::connect('/:slug', array('controller' => 'categories', 'action' => 'view'), 
                                                    array('pass' => array('slug')));

ここまでは、すべて問題なく動作し、リンクhttp://example.com/animals-and-petsにアクセスすると完璧に動作します。

このページにはページネーションがありますが、これは大きな問題であり、ページのリンクがhttp://example.com/categories/view/animals-and-pets/page:2のように間違って生成されます。

取得したい結果は ですexample.com/animals-and-pets/2

事前にご協力いただきありがとうございます。

4

1 に答える 1

0

私はかつてこのようにしました: CakePhp1.3ページネーターの宛先URLを変更しますか?

\page:2ただし、代わりに使用すると、はるかに簡単になります\2

Cake 2.0 では、 を呼び出して$this->Paginator->options()、残りのページネーション オプションの前にビューに正しい URL を設定します。何かのようなもの:

//Set the correct url for the pagination, cake will add the "page:" and "sort:" variables to this url
$this->Paginator->options(array('url'=> array('controller' => 'categories', 'action' => 'view', 'slug' => $this->params['pass'][0])));
//now display the pagination
echo $this->Paginator->counter(array('format' => __('Page {:page} of {:pages}')));
echo $this->Paginator->prev('«', array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next('»', array(), null, array('class' => 'next disabled'));

お役に立てれば

于 2012-06-29T15:21:03.900 に答える