|
|
동네 사람들의 정담이 오고가는 대청마루입니다. 무슨 글이든 좋아요. |
/**
* @brief 해당 document의 조회수 증가
**/
function updateReadedCount($oDocument) {
$document_srl = $oDocument->document_srl;
$member_srl = $oDocument->get('member_srl');
$logged_info = Context::get('logged_info');
// 조회수 업데이트가 되면 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);
// 세션 등록
$_SESSION['readed_document'][$document_srl] = true;
}
조회수 증가는 왠지 자신의 웹사이트에 있는 콘텐츠를 아무도 안읽는거 같은 기분을 느끼게 해줍니다 제가 운영하는 웹사이트
의 경우 하루 접속자가 많아봐야 100명 이 안되고 매번 들려주시는 분들이 접속하여 글을 읽습니다. 같은 아이피로 접속을 해서
글을 읽고 또 나중에 다시 와서 읽었던 글을 또 읽고 하거든요. 소규모 커뮤니티 웹사이트나 인트라넷으로 웹사이트를 돌리는
경우에도 좋은 콘텐츠가 있음에도 접속하는 IP가 제한되어 있기때문에 글 조회수가 안올라가면 왠지 아무도 내 글을 안보는 것
같은 기분을 들게해서 기분이 묘 할때가 많습니다. 위와 같이 느낌을 받는 분들은 아래의 방법대로 코드를 수정하시면 IP당 1개
의 조회수가 아닌 글을 읽을때마다 조회수가 증가 할수 있게 할수 있습니다.
-'비밀얌' 님의글
/zbxe/modules/document/ 에 있는 document.controller.php 열어보시면 480번줄쯤에 위코드를 지우시고 아래코드로 대체하시면됩니다.
1.2.0버전에 맞게 수정한것이라 다른버전에서는 코드오류가날수있습니다.
고수분들은 잘하시겟지만 초보분들을위해 끄적여봅니다.
파일도 올렷으니 따로수정한것없으신분은 파일 바꾸셔도됩니다. [백업은 필수..]
첨부파일 1.2.1버전추가 파일이름뒤에 [1.2.1]지우고 덮어씌워주세요
/**
* @brief 해당 document의 조회수 증가
**/
function updateReadedCount($oDocument) {
$document_srl = $oDocument->document_srl;
$member_srl = $oDocument->get('member_srl');
$logged_info = Context::get('logged_info');
// 조회수 업데이트가 되면 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);
// 세션 등록
$_SESSION['readed_document'][$document_srl] = true;
}
최신댓글