2012-11-19 2 views
4

제품을보기 전에 로그인하는 많은 확장 프로그램이 있지만 새로운 정보 페이지를 작성하여 작성한 특정 페이지에 대한 액세스 만 제한하려고합니다. 이것이 가능한가? 나는 또한 PHP에 익숙하지 않으므로 편집해야하는 파일과 위치를 알려주십시오. 미리 감사드립니다.OpenCart 정보 페이지 및 정보 페이지에만 로그인 할 수 있습니까?

+2

아래 답변을 수락해야합니다. 대답의 왼쪽에있는 진드기를 사용하십시오. 고맙습니다. – shadyyx

답변

5

시도 컨트롤러의 상단이 추가/정보/information.php 바로 지수() 함수 선언 후 당신이 암호로 보호 할 페이지의 ID와 {ID} 교체 (당신은 얻을 수 있습니다 URL의 ID 또는 SEO URL이있는 경우 관리자 섹션에서 확인).

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을 사용하여 정보 페이지 하지, 당신은이 경우를 수정해야한다고 가정했습니다.

내가 어디로 가야할지 혼란 스럽다면 컨트롤러/계정/account.php을보십시오.이 코드를 여기에서 가져 와서 특정 정보 페이지에 맞게 수정했습니다.

+2

@ user1835998 두 개 이상의 정보 페이지를 제한하려면 첫 번째 조건 (첫 번째 줄)을 다음으로 변경하십시오 :'((this this is> get [ 'information_id']) && in_array ($ this -> request-> get [ 'information_id'], 배열 (ID1, ID2, ID3))) {'. – shadyyx

+0

예, 'in_array'는 암호로 한 페이지 이상을 보호하려는 경우 더 좋습니다. – Stann0rz