웹마스터 팁

원본글 : http://sejin7940.co.kr/index.php?mid=xe_tips&document_srl=19264&page=1
제 사이트의 글을 퍼온거기에 말이 짧습니다. 양해 부탁드립니다.

----------------------------------------------------------------

지난 1년 여간은 저도 이 소스를 이용해서  이 기능 원하는 경우 고쳐주었는데.
아예 이번에  이 기능을 그대로 구현한 애드온으로 만들었기에   (애드온을 배포할지 Market 에 내놓을지 확실치가 않네요) 
이 소스는 반대로 배포해드립니다 ^^;;
 

커뮤니티 나 신규 사이트의 경우..  조회수를 증가시키고 픈 경우가 많이 생긴다.
그러나, XE자체에서는  자기글은 아예 안 되고 남의 글도 한번만 조회수 증가가 가능하다
(IP 자체로 막고 있기에.. 원책적으로는 방법이 없다.)


아래의 소스는  일반유저에게는 조회수 횟수 제한 풀고,  한번클릭시마다 1씩 올라가고
관리자의 경우는 조회수가 10씩 올라가는 소스이다. 조회수 횟수제한을 풀고
(추가로 끝에 적어둔걸 이용하면   고정된 값이 아니라 랜덤하게 증가시킬 수도 있다)

 

1.  modules/document/document.controller.php 에서

        function updateReadedCount(&$oDocument) {  에서

 

            // 조회수 업데이트가 되면 trigger 호출 (after)
            $output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);
            if(!$output->toBool()) return $output;
            // session에 정보로 조회수를 증가하였다고 생각하면 패스
            if($_SESSION['readed_document'][$document_srl]) return false;

            // 글의 작성 ip와 현재 접속자의 ip가 동일하면 패스
            if($document->ipaddress == $_SERVER['REMOTE_ADDR']) {
                $_SESSION['readed_document'][$document_srl] = true;
                return false;
            }

            // document의 작성자가 회원일때 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 판단후 세션 등록하고 패스
            if($member_srl && $logged_info->member_srl == $member_srl) {
                $_SESSION['readed_document'][$document_srl] = true;
                return false;
            }

            // 조회수 업데이트
            $args->document_srl = $document_srl;
            $output = executeQuery('document.updateReadedCount', $args);


전체를 주석처리하고..

하단에 기재


            // 권한 체크
            $oModuleModel = &getModel('module'+ ');
            $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
            $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));


     // 조회수 업데이트
            $args->document_srl = $document_srl;
           if($grant->manager) $output = executeQuery('document.updateReadedCount10', $args);
            else $output = executeQuery('document.updateReadedCount', $args);

 

2.   modules/document/queries/updateReadedCount10.xml  추가

<query id="updateReadedCount10" action="update">
    <tables>
        <table name="documents" />
    </tables>
    <columns>
        <column name="readed_count" var="readed_count" default="plus(10)" />
    </columns>
    <conditions>
        <condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
    </conditions>
</query>

 

3.  (추가사항)   만약.. 조회수를 랜덤으로 변하게 하고프면.

  1번 소스중에서 끝부분을 아래처럼 바꿔주면 됩니다.
  
  $args->document_srl = $document_srl;
  $hits = rand(6,10);
  if($grant->manager) $output = executeQuery('document.updateReadedCount'.$hits, $args);
  else $output = executeQuery('document.updateReadedCount', $args);

 
   그리고   modules/document/queries/updateReadedCount6.xml ~ modules/document/queries/updateReadedCount10.xml 
   plus() 값만 살짝 바꿔서 추가하면 됩니다 ^^

제목 글쓴이 날짜
최고관리자 이외에는 ''회원정보보기''를 막기 [13] 비나무 2008.07.10
간단한 ajax 채팅소스입니다. [12] 제로저아 2008.10.23
XE코어 관리와 업그레이드 10계명 [5] 우진홈 2011.10.30
1.4.5.10->1.5.06 전환 성공기 executeQuery오류 문제및 다량 문제 발생해결 [2] phonetest 2011.10.21
갑자기 로그인(관리자 및 회원)이 안되는 경우 [2] 비밀얌 2011.10.02
특정 확장변수를 로그인한 회원에게만 보이게 하기 [3] 비밀얌 2011.09.17
xe_member 테이블에서 extra_vars 필드 분리하기... [1] 맘편한넘 2011.02.26
로그인 위젯 질문드립니다. 소리없는 2011.08.31
[꽁수로 해결하자!] 모바일 레이아웃 적용시 파일 업로드 안 되는 문제 file 나루씡. 2011.08.28
조회수 제한 풀고, 조회수 증가값을 더 크게 하는 소스 [7] sejin7940 2011.08.21
내 PC에서 XE 빠르게 설치하는 방법 [7] 차오이 2011.04.10
비로그인시 본문대신 지정문구 보이기 [1] 도라란 2011.07.11
회원 관리자 두기.. DaKi 2011.05.09
1.4.5 업데이트후 로그인 안되시는 분들 [3] BlogJh 2011.04.03
제로보드 XE - 오토셋에 설치하기 [11] file 차오이 2007.08.11
사진링크가 깨져서 엉망이네요 [1] 김성회 2011.03.11
[권한이 없습니다] 권한에 따른 다른 메시지 출력하기 [10] [1] 반도체맨 2008.10.03
우분투 10.04 LTS, SSH 사용자 접속 제한 fsfsdas 2011.02.20
동일서버내 페이지에서 로그인정보 활용하기... [4] 수로 2008.09.06
XE공식레이아웃(xe_official_v2)에서 소셜XE로그인창 연동 ehdgkr97 2011.02.13