user3799115
user3799115

Reputation: 131

add parameter in current url in cakephp

how to add parameter in current url in cakephp ?

exemple current url :

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

I want add parameter and do a link

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

Upvotes: 2

Views: 2437

Answers (3)

Er.KT
Er.KT

Reputation: 2860

You can create URL like:

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

which will create link like View Page

Upvotes: 2

Monty Khanna
Monty Khanna

Reputation: 1120

Try this :

$this->request->query();

Example :

// 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

Upvotes: 1

Santosh Patel
Santosh Patel

Reputation: 539

You can write like below. and get parameter on your function.

$data = $this->params['url'];

http://localhost/testwebsite/posts/index?brand_id=1&shop_id=1

Upvotes: 0

Related Questions