0

ユーザーが場所を入力し、他のいくつかのオプションを選択して検索を実行できるようにする単純な GET フォームがあります。

したがって、現時点でこのアクションの URL は次のとおりです: controller/search?area=london&option1=whatever&option2=whateverelse

URL を次のようにしたい: controller/search/london?option1=whatever&option2=whateverelse

つまり、エリアの GET パラメータは URL に組み込まれますが、NVP としては組み込まれません。

これを行う方法はありますか?ルーティングについて少し混乱していますか、それとも別の方法がありますか?

ありがとう

4

1 に答える 1

1

Use routing and the CakeDC search plugin. If you do not have yet read about routing you should do it, its a very powerful feature.

Route::connect('/search/:city/*', array('controller' => 'search', 'action' => 'index'), array('pass' => array('city'), 'city' => 'a-zA-Z0-9_-]+')));

Just wrote that down without testing, try it if does not work put some effort into it. This will make the city become the first arg of SearchController::index($city = null);

The search plugin will help you with mapping the query params to search conditions that can be used to retrieve the data from the database, see its readme.md how to do it.

于 2013-06-05T10:19:48.820 に答える