商品を閲覧する前にログインが必要になる拡張機能などをよく見かけますが、新しい情報ページを作成して作成した特定のページだけにアクセスを制限したい。これは可能ですか?私はPHPにもあまり精通していないので、どのファイルをどこで編集する必要があるか教えてください. 前もって感謝します。
2256 次
1 に答える
5
index()関数宣言の直後にcontroller / information / information.phpの先頭にこれを追加して、{ID}をパスワードで保護するページのIDに置き換えてみてください(URLからIDを取得できます。管理セクションからのSEOURLがあります)。
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を使用していないと想定しています。使用している場合は、SSLを変更する必要があります。
これがどこに行くべきかについて混乱している場合は、controller / account / account.phpを見てください-私はそこからこのコードを取得し、特定の情報ページ用に変更しました。
于 2012-11-19T16:30:49.690 に答える