최근게시물의 기간조정은 어떻게 해야 하죠? 정보
최근게시물의 기간조정은 어떻게 해야 하죠?본문
기간을 조정해서 최근게시물을 출력하려고 합니다.
어느부분을 손대야 하는지 도움을 부탁드립니다.
댓글 전체
팁: http://www.sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=11232&page=3
적용사례: http://bitnuri.tv/index.php?gr_id=gr_best 기간별 설정에 위한 게시물 출력.
아래는 전체 소스입니다.
------------------------------------------
<?
// ucc 축출
function latest_ucc($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="",$options2="",$s_subject="",$s_turn="",$t_end="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
//정렬값이 없다면
if(!$options2)
$options2 = "wr_id";
//가로정렬값이 없는경우
if(!$options)
$options = 3;
//$bo_table 초기화, 이부분은 특정게시판을 사용하기 위함, 삭제하세요.
$bo_table = "";
$bo_table = "product";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
//기간별 조건검색이 없는경우
if(!$s_turn){
$s_turn = 365; // 조건값이 없을경우 1년 이내의 자료만 검색
}
$s_day = 24;
$s_time = $s_day*$s_turn; //정수값을 1일로 환산처리.
$now_time = $g4[time_ymdhis]; //현재시간기준, 삭제해도 됨.
$s_start = date("Y-m-d H:i:s", time()-3600 * $s_time);
//기간별 조건검색이 없는경우
if(!$t_end){
$t_end = $g4[time_ymdhis];; // 현재시간
}
else{
$t_day = 24;
$t_time = $s_day*$t_end; //정수값을 1일로 환산처리.
$now_time = $g4[time_ymdhis]; //현재시간기준, 삭제해도 됨.
$t_end = date("Y-m-d H:i:s", time()-3600 * $t_time);
}
//조건
$s_mct = "wr_is_comment = 0 ";
$s_mct .= " and wr_datetime >= '$s_start'";
$s_mct .= " and wr_datetime <= '$t_end'";
$sql = " select * from $tmp_write_table where $s_mct order by $options2 desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
적용사례: http://bitnuri.tv/index.php?gr_id=gr_best 기간별 설정에 위한 게시물 출력.
아래는 전체 소스입니다.
------------------------------------------
<?
// ucc 축출
function latest_ucc($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="",$options2="",$s_subject="",$s_turn="",$t_end="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
//정렬값이 없다면
if(!$options2)
$options2 = "wr_id";
//가로정렬값이 없는경우
if(!$options)
$options = 3;
//$bo_table 초기화, 이부분은 특정게시판을 사용하기 위함, 삭제하세요.
$bo_table = "";
$bo_table = "product";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
//기간별 조건검색이 없는경우
if(!$s_turn){
$s_turn = 365; // 조건값이 없을경우 1년 이내의 자료만 검색
}
$s_day = 24;
$s_time = $s_day*$s_turn; //정수값을 1일로 환산처리.
$now_time = $g4[time_ymdhis]; //현재시간기준, 삭제해도 됨.
$s_start = date("Y-m-d H:i:s", time()-3600 * $s_time);
//기간별 조건검색이 없는경우
if(!$t_end){
$t_end = $g4[time_ymdhis];; // 현재시간
}
else{
$t_day = 24;
$t_time = $s_day*$t_end; //정수값을 1일로 환산처리.
$now_time = $g4[time_ymdhis]; //현재시간기준, 삭제해도 됨.
$t_end = date("Y-m-d H:i:s", time()-3600 * $t_time);
}
//조건
$s_mct = "wr_is_comment = 0 ";
$s_mct .= " and wr_datetime >= '$s_start'";
$s_mct .= " and wr_datetime <= '$t_end'";
$sql = " select * from $tmp_write_table where $s_mct order by $options2 desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
기간을 조정해서 최근게시물을 출력하려고 합니다.
==>> 최신 게시물의 기간조정을 하려면... " 시작일 ~ 최근일 " 을 축출할려면...결국 latest skin함수를 변형해야 합니다.
가령 위의 내용을 서술하면. 30일 부터 5일까지의 wr_hit 순으로 출력할경우 사용하시면 될듯 하구요. 해당 스킨은 그대로 최근게시물과 동일합니다. 즉, 결과물을 조건식으로 처리하시면 됩니다.
응용방법: 1개월전의 최근베스트 게시물 10개 축출, 지난 과거 뉴스 출력 등...
위 함수를 이용하시면 순위 사이트로도 확대가 가능합니다.
적용사례: http://fashionlist.co.kr/index.php?gr_id=top_num
==>> 최신 게시물의 기간조정을 하려면... " 시작일 ~ 최근일 " 을 축출할려면...결국 latest skin함수를 변형해야 합니다.
가령 위의 내용을 서술하면. 30일 부터 5일까지의 wr_hit 순으로 출력할경우 사용하시면 될듯 하구요. 해당 스킨은 그대로 최근게시물과 동일합니다. 즉, 결과물을 조건식으로 처리하시면 됩니다.
응용방법: 1개월전의 최근베스트 게시물 10개 축출, 지난 과거 뉴스 출력 등...
위 함수를 이용하시면 순위 사이트로도 확대가 가능합니다.
적용사례: http://fashionlist.co.kr/index.php?gr_id=top_num