엑스엠엘님의 전체 게시판 인기글 뽑기 - 수정판 정보
엑스엠엘님의 전체 게시판 인기글 뽑기 - 수정판관련링크
본문
엑스엠엘님의
" 전체 게시판에서 최근 게시물 대상으로 인기글 뽑기 "
소스는 댓글도 같이 나오는 문제점이 있었습니다.
이 문제점하고 게시판 이름이 나오도록 수정하였습니다.
그리고 출력하기 실은 게시판 출력안하기 옵션도 넣었습니다
아래 글은 원글을 그대로 사용하였고 제가 추가한 부분만 표시 하였습니다
기존 latest() 스킨에서 사용할 변수는
$list[ $i]['hit'] // 조회수
$list[ $i]['name'] // 작성자 이름 사이드뷰
$list[$i][href] // 게시물 링크
$list[$i][subject] // 게시물 제목 글자수 자른것
$list[$i]['wr_subject'] // 게시물 제목 글자수 안자른것
$list[$i]['bo_subject'] // 게시판 이름
입니다.
소스입니다.
/* 사용법
<?=topofall('latest skin name', '불러 올 갯수', '제목 길이', '제외할게시판ID')?>
제외할 게시판 ID 사용법 :보드ID1|보드ID2|보드ID3 <=| 파이프로 분리
by *** 개인정보보호를 위한 이메일주소 노출방지 ***
*/
lib/topofall.lib.php
<?php
if (!defined('_GNUBOARD_')) exit;
function topofall($skin_dir="", $rows=10, $subject_len=40,$option="") {
function cmp($a, $b)
{
if ($a['hit'] == $b['hit']) {
return 0;
}
return ($a['hit'] > $b['hit']) ? -1 : 1;
}
global $config; //함수외부에서 정의된 전역변수 $config를 불러옴
global $g4; //함수외부에서 정의된 전역변수 $g4를 불러옴
if ($skin_dir) //만약에 $skin_dir의 값이 있다면
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir"; //해당 $skin_dir의 디랙토리의 스킨사용
else //그렇지 않다면?
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]"; //기본스킨사용
$noboard ='';
if($option){
$option_arr = explode("|",$option);
$option_cnt = count($option_arr);
$noboard = "and bo_table not in (";
for($i=0;$i<$option_cnt;$i++){
$noboard .= "'{$option_arr[$i]}'";
if($i != ($option_cnt-1) ) $noboard .= ", ";
}
$noboard .= ")";
}
$sqln= "select bo_table, wr_id from {$g4['board_new_table']} where bn_datetime > ( now() - interval 48 hour) and bn_id > 1 and wr_id = wr_parent {$noboard} order by bn_id desc limit 100";
$resn= mysql_query( $sqln);
$sqlall= array();
if( $resn) while( $row= mysql_fetch_assoc( $resn)) {
$sqlall[]="select wr_name, wr_subject, wr_hit, '{$row['bo_table']}' bo_table, wr_id from g4_write_{$row['bo_table']} where wr_id='{$row['wr_id']}' and wr_is_comment = '0' ";
}
if( count( $sqlall) > 0) {
$usql= implode( ' union all ', $sqlall);
$listall = array(); //$list에 담는다
$result = sql_query($usql);
for ($i=0; $row = sql_fetch_array($result); $i++) //사용자함수로 불러올 갯수대로 for문을 돌림
$row2 = sql_fetch("select bo_subject from $g4[board_table] where bo_table = '$row[bo_table]' ");
$listall[$i] = array( 'hit'=> $row['wr_hit'], 'name'=>$row['wr_name'],
'wr_subject'=> $row['wr_subject'], 'bo_subject'=> $row2[bo_subject], 'href'=>$g4['bbs'].'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'],
'subject'=>conv_subject( $row['wr_subject'], $subject_len) );
usort( $listall, 'cmp');
$list= array_slice( $listall, 0, $rows);
} else $list=array();
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content; //$content에 반환
}
?>
좋은 소스인데 많은 분들이 제대로 사용하지 못한거 같아 많이 아쉽습니다
스킨 제작 시 좀더 유용하라고 게시판 이름과 덧글은 제외 되도록 수정하였어요
" 전체 게시판에서 최근 게시물 대상으로 인기글 뽑기 "
소스는 댓글도 같이 나오는 문제점이 있었습니다.
이 문제점하고 게시판 이름이 나오도록 수정하였습니다.
그리고 출력하기 실은 게시판 출력안하기 옵션도 넣었습니다
아래 글은 원글을 그대로 사용하였고 제가 추가한 부분만 표시 하였습니다
기존 latest() 스킨에서 사용할 변수는
$list[ $i]['hit'] // 조회수
$list[ $i]['name'] // 작성자 이름 사이드뷰
$list[$i][href] // 게시물 링크
$list[$i][subject] // 게시물 제목 글자수 자른것
$list[$i]['wr_subject'] // 게시물 제목 글자수 안자른것
$list[$i]['bo_subject'] // 게시판 이름
입니다.
소스입니다.
/* 사용법
<?=topofall('latest skin name', '불러 올 갯수', '제목 길이', '제외할게시판ID')?>
제외할 게시판 ID 사용법 :보드ID1|보드ID2|보드ID3 <=| 파이프로 분리
by *** 개인정보보호를 위한 이메일주소 노출방지 ***
*/
lib/topofall.lib.php
<?php
if (!defined('_GNUBOARD_')) exit;
function topofall($skin_dir="", $rows=10, $subject_len=40,$option="") {
function cmp($a, $b)
{
if ($a['hit'] == $b['hit']) {
return 0;
}
return ($a['hit'] > $b['hit']) ? -1 : 1;
}
global $config; //함수외부에서 정의된 전역변수 $config를 불러옴
global $g4; //함수외부에서 정의된 전역변수 $g4를 불러옴
if ($skin_dir) //만약에 $skin_dir의 값이 있다면
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir"; //해당 $skin_dir의 디랙토리의 스킨사용
else //그렇지 않다면?
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]"; //기본스킨사용
$noboard ='';
if($option){
$option_arr = explode("|",$option);
$option_cnt = count($option_arr);
$noboard = "and bo_table not in (";
for($i=0;$i<$option_cnt;$i++){
$noboard .= "'{$option_arr[$i]}'";
if($i != ($option_cnt-1) ) $noboard .= ", ";
}
$noboard .= ")";
}
$sqln= "select bo_table, wr_id from {$g4['board_new_table']} where bn_datetime > ( now() - interval 48 hour) and bn_id > 1 and wr_id = wr_parent {$noboard} order by bn_id desc limit 100";
$resn= mysql_query( $sqln);
$sqlall= array();
if( $resn) while( $row= mysql_fetch_assoc( $resn)) {
$sqlall[]="select wr_name, wr_subject, wr_hit, '{$row['bo_table']}' bo_table, wr_id from g4_write_{$row['bo_table']} where wr_id='{$row['wr_id']}' and wr_is_comment = '0' ";
}
if( count( $sqlall) > 0) {
$usql= implode( ' union all ', $sqlall);
$listall = array(); //$list에 담는다
$result = sql_query($usql);
for ($i=0; $row = sql_fetch_array($result); $i++) //사용자함수로 불러올 갯수대로 for문을 돌림
$row2 = sql_fetch("select bo_subject from $g4[board_table] where bo_table = '$row[bo_table]' ");
$listall[$i] = array( 'hit'=> $row['wr_hit'], 'name'=>$row['wr_name'],
'wr_subject'=> $row['wr_subject'], 'bo_subject'=> $row2[bo_subject], 'href'=>$g4['bbs'].'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'],
'subject'=>conv_subject( $row['wr_subject'], $subject_len) );
usort( $listall, 'cmp');
$list= array_slice( $listall, 0, $rows);
} else $list=array();
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content; //$content에 반환
}
?>
좋은 소스인데 많은 분들이 제대로 사용하지 못한거 같아 많이 아쉽습니다
스킨 제작 시 좀더 유용하라고 게시판 이름과 덧글은 제외 되도록 수정하였어요
추천
4
4
댓글 6개
추천글로 뽑으려면 어떻게 하죠?
좋은 팁이군요. 저희도 활용해보도록 하겠습니다
뭐라고 질문을 드려야 할지...
전 게시글이 없다고 나옵니다.
아직 테스트중인 홈페이지라.. 신규로 등록한 게시글이 없어서 그런지.. 이전에 게시글을 올렸는데 날짜가 너무 지나서 안보이는것인지...잘 모르겠네요
날짜와 상관이 없이 모든게시판의 hit순위를 뽑아오려면 어떻게 해야 하는지요...
전 게시글이 없다고 나옵니다.
아직 테스트중인 홈페이지라.. 신규로 등록한 게시글이 없어서 그런지.. 이전에 게시글을 올렸는데 날짜가 너무 지나서 안보이는것인지...잘 모르겠네요
날짜와 상관이 없이 모든게시판의 hit순위를 뽑아오려면 어떻게 해야 하는지요...
이 소스는 board_new 테이블에서 글을 뽑아 오기 때문에
최근 게시물이 없으면 게시물이 나타나지 않습니다.
또한 관리자 설정에서 최근게시물 삭제를 자주 하신다면 목록이 안나올수도 있고요
최근 게시물이 없으면 게시물이 나타나지 않습니다.
또한 관리자 설정에서 최근게시물 삭제를 자주 하신다면 목록이 안나올수도 있고요
감사합니다.
전체 게시판에서 hit순으로 불러오는것은 없나요?
전체 게시판에서 hit순으로 불러오는것은 없나요?
gg