원하는 게시판의 내용을 최신글로 쓰고 싶어서 적용했는데, 잘 되질 않습니다. 채택완료
https://sir.kr/g5_tip/4103">https://sir.kr/g5_tip/4103
그누위즈님이 작성한 소스대로 수정을 했습니다만, 기존이랑 동일합니다.
이유가 뭘까요?
latest.lib 내 소스도 추가했구요.
// 최신글 추출 // $cache_time 캐시 갱신시간 function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='') { global $g5;
if (!$skin_dir) $skin_dir = 'basic';
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) { if (G5_IS_MOBILE) { $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; if(!is_dir($latest_skin_path)) $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path); } else { $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path); } $skin_dir = $match[1]; } else { if(G5_IS_MOBILE) { $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; $latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; } else { $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir; $latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir; } }
$cache_fwrite = false; if(G5_USE_CACHE) { $cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";
if(!file_exists($cache_file)) { $cache_fwrite = true; } else { if($cache_time > 0) { $filetime = filemtime($cache_file); if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) { @unlink($cache_file); $cache_fwrite = true; } }
if(!$cache_fwrite) include($cache_file); } }
if(!G5_USE_CACHE || $cache_fwrite) { $list = array();
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' "; $board = sql_fetch($sql); $bo_subject = get_text($board['bo_subject']);
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름 $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} "; $result = sql_query($sql); for ($i=0; $row = sql_fetch_array($result); $i++) { $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len); }
if($cache_fwrite) { $handle = fopen($cache_file, 'w'); $cache_content = ""; fwrite($handle, $cache_content); fclose($handle); } }
ob_start(); include $latest_skin_path.'/latest.skin.php'; $content = ob_get_contents(); ob_end_clean();
return $content; }
?>
global $g5;
if (!$skin_dir) $skin_dir = 'basic';
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) { if (G5_IS_MOBILE) { $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; if(!is_dir($latest_skin_path)) $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path); } else { $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path); } $skin_dir = $match[1]; } else { if(G5_IS_MOBILE) { $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; $latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; } else { $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir; $latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir; } }
$list = array(); $sql_common = " from {$g5['board_new_table']} a where find_in_set(a.bo_table, '{$bo_tables}')"; $sql_common .= " and a.wr_id = a.wr_parent "; $sql_order = " order by a.bn_id desc "; $sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";
$result = sql_query($sql); for ($i=0; $row=sql_fetch_array($result); $i++) {
$sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";
$board = sql_fetch($sql);
$tmp_write_table = $g5['write_prefix'] . $row['bo_table']; $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");
$list[$i] = $row2; $list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len); $list[$i]['bo_subject'] = $row['bo_subject']; $list[$i]['bo_table'] = $row['bo_table']; }
ob_start(); include $latest_skin_path.'/latest.skin.php'; $content = ob_get_contents(); ob_end_clean();
return $content; } ?>
index페이지에 echo latest_all("simple_gallery", "active_support01,self_support02", 3, 15); 소스도 추가했습니다만, 한개의 게시판 내용만 나옵니다. 갤러리 뿐만아니라 베이직도 동일합니다.
봐주시길 부탁드립니다.
답변 2개
답변을 작성하려면 로그인이 필요합니다.
로그인
홈페이지 주소는 ilhanu.or.kr 입니다.
요것만 드리면 될까요?
정말 감사드립니다.