php – 是否可以要求登录OpenCart Information页面,而且只需要信
发布时间:2020-12-13 17:22:01 所属栏目:PHP教程 来源:网络整理
导读:我看到许多扩展程序让您在查看产品之前登录,但我只想限制通过创建新信息页面访问我创建的某个页面.这可能吗?我也不是很熟悉php所以请告诉我我应该编辑哪些文件以及在哪里.提前致谢. 解决方法 尝试在index()函数声明后直接在controller / information / info
我看到许多扩展程序让您在查看产品之前登录,但我只想限制通过创建新信息页面访问我创建的某个页面.这可能吗?我也不是很熟悉php所以请告诉我我应该编辑哪些文件以及在哪里.提前致谢.
解决方法
尝试在index()函数声明后直接在controller / information / information.php的顶部添加它,并将{ID}替换为您要密码保护的页面的ID(您可以从URL获取ID,或者如果你有SEO网址,来自管理部分).
if (isset($this->request->get['information_id']) && $this->request->get['information_id'] == '{ID}') { //If the information_id is provided and it matches the ID you wish to protect if (!$this->customer->isLogged()) { //If the customer is not logged in already,redirect them to the login page //Use $this->session->data['redirect'] to redirect them back to this page after logging in $this->session->data['redirect'] = $this->url->link('information/information','information_id=' . $this->request->get['information_id']); //Do the redirect $this->redirect($this->url->link('account/login','','SSL')); } } 我假设信息页面在上面的例子中没有使用SSL,如果是的话你需要修改它. 如果你对这应该去哪里感到困惑,请看看controller / account / account.php – 我从那里获取了这些代码,并为特定的信息页面修改了它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |