嗨,我想在我必须
通过邮件发送的URL链接中设置一个关键字值,因此单击该链接后,用户将进入我的网站,我想通过此$this->params['url']
读取该关键字值,在获得此值后,我必须为我的视图页面设置它,所有结果将根据关键字值出现。我对不同的电子邮件有不同的关键字,所以根据收件人邮件,当他/她点击它时,他/她应该根据他/她在他/她的视图中的关键字获得结果。 所有编码都是在 cakephp 中完成的
如果你的操作是——
public function identify_user($userId = null){
}
然后任何 URL 都以 www.example.com/users/identify_user/4 $userId
为 4
现在,如果
public function identify_user($userId = null, $identificationId = null){
}
然后任何 URL 都以 www.example.com/users/identify_user/4/abcdef12345
形式出现,$userId
为 4,$identificationId
为 abcdef12345;
还有其他方法,如命名参数或查询参数。命名参数查找为名称 => $value;(注意:尽量避免命名参数,它会贬值(
您可以使用查询参数构建 url,然后使用$this->request->query();
准备好查询参数
现在如何构建网址?
如果您使用第一种方法均值通过参数,则 bulid 链接为 -
$link = $this->Html->link('Link name to display', array('controller' => 'Users', 'action' => 'identify_user', $user['User']['id']));
这里$user['User']['id']
来自数据库;
命名参数:
$link = $this->Html->link('Link name to display', array(
'controller' => 'Users',
'action' => 'identify_user',
'user_name' => $user['User']['name'],
'unique_id' => String::uuid()
)
);
读取命名参数-
$this->request->params['named']['unique_id'];
查询参数-
$link = $this->Html->link('Link name to display', array(
'controller' => 'Users',
'action' => 'identify_user',
'?' => array(
'user_name' => $user['User']['name'],
'unique_id' => String::uuid()
)
)
);
读取查询参数-$this->request->query('unique_id'(;