2016-01-28 45 views
1

如何在cakephp的當前網址中添加參數?在cakephp的當前網址中添加參數

爲例 當前網址:

http://localhost/testwebsite/posts/index/Search.brand_id:1 

我要添加參數,並做了鏈接

http://localhost/testwebsite/posts/index/Search.brand_id:1/Search.shop_id:1 

回答

1

試試這個:

$this->request->query(); 

例子:

// url array 
array('ext' => 'json', '?' => array('foo' => 'bar') 

// resulting url 
/controller/action.json?foo=bar 

$foo = $this->request->query('foo'); 
// returns "bar" in our example - or null if no foo key is found 
1

您可以創建URL,如:

echo $this->Html->link('View Page', array(
    'controller' => 'page', 
    'action' => 'view', 
    '?' => array('Search.brand_id' => 1, 'Search.shop_id' => 1)) 
); 

這將創建鏈接像View Page