그룹 최신글 적용 안 됨. 채택완료
https://sir.kr/g5_skin/4213">https://sir.kr/g5_skin/4213
위 코드를 변형해 그룹 최신글을 만들었습니다.
아래의 주소고요.
http://attm.kr/">http://attm.kr/
그런데 아래와 같이
갑작이 그룹글이 잘 추출되지 않습니다.
어떤이유로 한 그룹의 한 카테고리 글만 나오네요.
왜그럴까요.?
https://sir.kr/bbs/view_image.php?fn=%2Fdata%2Feditor%2F1710%2F31474690_1509353964.1251.png" target="_blank">https://sir.kr/data/editor/1710/thumb-31474690_1509353964.1251_650x405.png" style="height:594px; width:954px" />
답변 3개
답변에 대한 댓글 3개
-----------------------------------------------------------------------
같은 스킨으로 여러 그룹의 최신글을 뽑아오고자 할 때 오류가 있을 듯 합니다.
latest.lib.php
96 번째 줄 부근에
$cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";
이렇게 캐시 파일을 지정하는데 여기에 $bo_table은 없으므로
$cache_file = G5_DATA_PATH."/cache/latest-{$gr_id}-{$skin_dir}-{$rows}-{$subject_len}.php";
이런식으로 $bo_table 을 $gr_id 로 바꿔야 할 듯합니다.
-----------------------------------------------------------------------
저도 올려주신 사이트 들어가서 확인하니 bo_table이 아닌 gr_id로 되있더라구요
이거 적용해보시는건...?
추가로
-------------------------
get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $thumb_width, $thumb_height);
이렇게 하시면 이미지 출력 가능합니다.
-------------------------
그렇답니다.
함수는 latest와 그룹추출 함수 latest2로 두개입니다.
<?php
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
// $cache_time 캐시 갱신시간
function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
//카테고리 추출 2줄
list($bo_table, $category) = explode("|", $bo_table);
if($category) $where = " AND ca_name = '".$category."' ";
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} ";
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0".$where." 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 = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".sql_escape_string($bo_subject)."';\n\$list=".var_export($list, true)."?>";
fwrite($handle, $cache_content);
fclose($handle);
}
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
//그룹 최신글
function latest2($skin_dir='', $gr_id, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
//static $css = array();
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-{$gr_id}-{$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)
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
<div id="toptitle">
<div id="top_subj">
<a href="/bbs/board.php?bo_table=feature"><span> latest</span></a>
</div>
<div id="explane">
<span> 함께한 순간의 기록</span>
</div>
</div>
그렇다면
<?php echo latest2("theme/table_group_gallery", "feature", "6", "150");?>
이렇게 되겠지요