스벅 쿠폰 드릴게요 최신글 도와주세요 급합니다 ㅠㅠ 채택완료
개발자 없이 혼자 기본 홍보, 쇼핑몰은 구축이 가능해서 5년째 일하는 중입니다.(그누보드 사용)
모르는건 카페나 그누보드 찾아 보고 물어보면서 하는데 이번은 정말 모르겠어서 여기다 급하게 부탁드려요 ㅠㅠ
일반 게시판에 베스트/신상품 체크박스를 만들어서 메인 최신글에 노출이 되게 만들었는데요
문제는 한 게시판이 아닌 여러개 게시판의 글을 가지고 와야 하거든요
latest.lib.php 여기에
http://sir.kr/data/editor/2411/33102762_1731976613.1049.png" width="100%" />
이거를 추가해서 넣어서 메인 베스트/신상품 체크박스 선택했을 때 노출되게 해놨구요
여기서 다중 최신글을을 만들려면 latest_all에 추가해서 수정해야하거든요
이 부분 좀 도와주시면 너무 너무 감사하겠습니다.
해결해주시는 분께 스벅 커피쿠폰 보내드릴게요~ㅠㅠ
</p>
<p><?php
if (!defined('_GNUBOARD_')) exit;
@include_once(G5_LIB_PATH.'/thumbnail.lib.php');</p>
<p>// 최신글 추출
// $cache_time 캐시 갱신시간</p>
<p>function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='',$where=array())
{
global $g5;</p>
<p> if (!$skin_dir) $skin_dir = 'basic';
$time_unit = 3600; // 1시간으로 고정</p>
<p> 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;
}
}</p>
<p> $caches = false;</p>
<p> if(G5_USE_CACHE) {
$cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();
$caches = g5_get_cache($cache_file_name, (int) $time_unit * (int) $cache_time);
$cache_list = isset($caches['list']) ? $caches['list'] : array();
g5_latest_cache_data($bo_table, $cache_list);
}</p>
<p> if( $caches === false ){</p>
<p> $list = array();</p>
<p> $board = get_board_db($bo_table, true);</p>
<p> if( ! $board ){
return '';
}</p>
<p> $bo_subject = get_text($board['bo_subject']);</p>
<p> $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름</p>
<p> </p>
<p> $add_where = '';
if(count($where)){
foreach ($where as $key=>$val){
$add_where.= " and {$key} = '{$val}' ";
}
}
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 {$add_where} order by wr_num limit 0, {$rows} ";</p>
<p>
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
try {
unset($row['wr_password']); //패스워드 저장 안함( 아예 삭제 )
} catch (Exception $e) {
}
$row['wr_email'] = ''; //이메일 저장 안함
if (strstr($row['wr_option'], 'secret')){ // 비밀글일 경우 내용, 링크, 파일 저장 안함
$row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';
$row['file'] = array('count'=>0);
}
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);</p>
<p> $list[$i]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "and bf_type in (1, 2, 3, 18) ", true) : array('bf_file'=>'', 'bf_content'=>'');
$list[$i]['bo_table'] = $bo_table;
// 썸네일 추가
if($options && is_string($options)) {
$options_arr = explode(',', $options);
$thumb_width = $options_arr[0];
$thumb_height = $options_arr[1];
$thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);
// 이미지 썸네일
if($thumb['src']) {
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
$list[$i]['img_thumbnail'] = '<a href="'.$list[$i]['href'].'" class="lt_img">'.$img_content.'</a>';
// } else {
// $img_content = '<img src="'. G5_IMG_URL.'/no_img.png'.'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="no_img">';
}
}</p>
<p> if(! isset($list[$i]['icon_file'])) $list[$i]['icon_file'] = '';
}
g5_latest_cache_data($bo_table, $list);</p>
<p> if(G5_USE_CACHE) {</p>
<p> $caches = array(
'list' => $list,
'bo_subject' => sql_escape_string($bo_subject),
);</p>
<p> g5_set_cache($cache_file_name, $caches, (int) $time_unit * (int) $cache_time);
}
} else {
$list = $cache_list;
$bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';
}</p>
<p> ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();</p>
<p> return $content;
}</p>
<p>?></p>
<p>
<?php
// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)
function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='',$where=array())
{
global $g5;</p>
<p> if (!$skin_dir) $skin_dir = 'basic';</p>
<p> 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;
}
}</p>
<p> $list = array();</p>
<p> $add_where = '';
if(count($where)){
foreach ($where as $key=>$val){
$add_where.= " and {$key} = '{$val}' ";
}
}
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 {$add_where} order by wr_num limit 0, {$rows} ";</p>
<p>
$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_datetime desc, a.bn_id desc ";
$sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";</p>
<p> $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);</p>
<p> $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");</p>
<p> $list[$i] = $row2;
$list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);
//$list[$i]['bo_subject'] = $row['bo_subject'];
$list[$i]['bo_subject'] = $board['bo_subject'];
$list[$i]['bo_table'] = $row['bo_table'];
}</p>
<p> ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();</p>
<p> return $content;
}
?>
</p>
<p>
답변 5개
latest_all 함수에 해당 전체 테이블 쿼리가 제대로 가져오는지 부터 체크해서 확인이 필요한 부분입니다.
만약 잘 모르신다면 제작의뢰나 쪽지로 정보 주셔야만 체크후 대응이 가능 사항인 부분이라서요
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
</p>
<p><?php</p>
<p>if (!defined('_GNUBOARD_')) exit;</p>
<p>@include_once(G5_LIB_PATH.'/thumbnail.lib.php');</p>
<p> </p>
<p>// 스킨 경로 및 URL 설정 함수</p>
<p>function get_skin_path($skin_dir) {</p>
<p> global $g5;</p>
<p> if (preg_match('#^theme/(.+)$#', $skin_dir, $match)) {</p>
<p> if (G5_IS_MOBILE) {</p>
<p> $skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];</p>
<p> if (!is_dir($skin_path)) {</p>
<p> $skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];</p>
<p> }</p>
<p> } else {</p>
<p> $skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];</p>
<p> }</p>
<p> $skin_url = str_replace(G5_PATH, G5_URL, $skin_path);</p>
<p> return [$skin_path, $skin_url, $match[1]];</p>
<p> } else {</p>
<p> if (G5_IS_MOBILE) {</p>
<p> $skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;</p>
<p> $skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;</p>
<p> } else {</p>
<p> $skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;</p>
<p> $skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;</p>
<p> }</p>
<p> return [$skin_path, $skin_url, $skin_dir];</p>
<p> }</p>
<p>}</p>
<p> </p>
<p>// 최신글 추출 함수</p>
<p>function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='', $where=array()) {</p>
<p> global $g5;</p>
<p> </p>
<p> if (!$skin_dir) $skin_dir = 'basic';</p>
<p> list($latest_skin_path, $latest_skin_url, $skin_dir) = get_skin_path($skin_dir);</p>
<p> </p>
<p> $caches = false;</p>
<p> if (G5_USE_CACHE) {</p>
<p> $cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();</p>
<p> $caches = g5_get_cache($cache_file_name, 3600 * $cache_time);</p>
<p> $cache_list = isset($caches['list']) ? $caches['list'] : array();</p>
<p> g5_latest_cache_data($bo_table, $cache_list);</p>
<p> }</p>
<p> </p>
<p> if ($caches === false) {</p>
<p> $list = array();</p>
<p> $board = get_board_db($bo_table, true);</p>
<p> if (!$board) {</p>
<p> return ''; // 게시판이 없을 경우 빈 문자열 반환</p>
<p> }</p>
<p> $bo_subject = get_text($board['bo_subject']);</p>
<p> $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름</p>
<p> </p>
<p> $add_where = '';</p>
<p> if (count($where)) {</p>
<p> foreach ($where as $key => $val) {</p>
<p> $add_where .= " AND {$key} = '".sql_escape_string($val)."' ";</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> $sql = "SELECT * FROM {$tmp_write_table} WHERE wr_is_comment = 0 {$add_where} ORDER BY wr_num LIMIT 0, {$rows}";</p>
<p> </p>
<p> $result = sql_query($sql);</p>
<p> while ($row = sql_fetch_array($result)) {</p>
<p> unset($row['wr_password']); // 패스워드 저장 안함</p>
<p> $row['wr_email'] = ''; // 이메일 저장 안함</p>
<p> if (strstr($row['wr_option'], 'secret')) { // 비밀글일 경우 내용 저장 안함</p>
<p> $row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';</p>
<p> $row['file'] = array('count' => 0);</p>
<p> }</p>
<p> $list[] = get_list($row, $board, $latest_skin_url, $subject_len);</p>
<p> $list[count($list) - 1]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "AND bf_type IN (1, 2, 3, 18)", true) : array('bf_file' => '', 'bf_content' => '');</p>
<p> </p>
<p> // 썸네일 추가</p>
<p> if ($options && is_string($options)) {</p>
<p> $options_arr = explode(',', $options);</p>
<p> $thumb_width = $options_arr[0];</p>
<p> $thumb_height = $options_arr[1];</p>
<p> $thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);</p>
<p> if ($thumb['src']) {</p>
<p> $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';</p>
<p> $list[count($list) - 1]['img_thumbnail'] = '<a href="'.$list[count($list) - 1]['href'].'" class="lt_img">'.$img_content.'</a>';</p>
<p> }</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> g5_latest_cache_data($bo_table, $list);</p>
<p> </p>
<p> if (G5_USE_CACHE) {</p>
<p> $caches = array(</p>
<p> 'list' => $list,</p>
<p> 'bo_subject' => sql_escape_string($bo_subject),</p>
<p> );</p>
<p> g5_set_cache($cache_file_name, $caches, 3600 * $cache_time);</p>
<p> }</p>
<p> } else {</p>
<p> $list = $cache_list;</p>
<p> $bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';</p>
<p> }</p>
<p> </p>
<p> ob_start();</p>
<p> include $latest_skin_path.'/latest.skin.php';</p>
<p> $content = ob_get_contents();</p>
<p> ob_end_clean();</p>
<p> return $content;</p>
<p>}</p>
<p> </p>
<p>// 여러 게시판의 최신글 추출 함수</p>
<p>function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='', $where=array()) {</p>
<p> global $g5;</p>
<p> </p>
<p> if (!$skin_dir) $skin_dir = 'basic';</p>
<p> list($latest_skin_path, $latest_skin_url, $skin_dir) = get_skin_path($skin_dir);</p>
<p> </p>
<p> $list = array();</p>
<p> $add_where = '';</p>
<p> if (count($where)) {</p>
<p> foreach ($where as $key => $val) {</p>
<p> $add_where .= " AND {$key} = '".sql_escape_string($val)."' ";</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> $sql_common = " FROM {$g5['board_new_table']} a WHERE FIND_IN_SET(a.bo_table, '{$bo_tables}')";</p>
<p> $sql_common .= " AND a.wr_id = a.wr_parent ";</p>
<p> $sql_order = " ORDER BY a.bn_datetime DESC, a.bn_id DESC ";</p>
<p> $sql = "SELECT a.* {$sql_common} {$sql_order} LIMIT 0, {$rows}";</p>
<p> </p>
<p> $result = sql_query($sql);</p>
<p> while ($row = sql_fetch_array($result)) {</p>
<p> $sql = "SELECT * FROM {$g5['board_table']} WHERE bo_table = '{$row['bo_table']}'";</p>
<p> $board = sql_fetch($sql);</p>
<p> $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];</p>
<p> $row2 = sql_fetch("SELECT * FROM {$tmp_write_table} WHERE wr_id = '{$row['wr_id']}'");</p>
<p> </p>
<p> if ($row2) {</p>
<p> $list[] = get_list($row2, $board, $latest_skin_url, $subject_len);</p>
<p> $list[count($list) - 1]['bo_subject'] = $board['bo_subject'];</p>
<p> $list[count($list) - 1]['bo_table'] = $row['bo_table'];</p>
<p> }</p>
<p> }</p>
<p> </p>
<p> ob_start();</p>
<p> include $latest_skin_path.'/latest.skin.php';</p>
<p> $content = ob_get_contents();</p>
<p> ob_end_clean();</p>
<p> return $content;</p>
<p>}</p>
<p>?> </p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
</p>
<p> <?php</p>
<p> echo latest_all('theme/basic', 'free,qa,notice,gallery', 10, 23);</p>
<p> ?></p>
<p>
이렇게 하면 잘 가지고 오는것 확인했습니다.
단, 링크만 오류가 나서 skin 을 수정해야 합니다.
latest.skin.php 파일에서 아래 부분 수정
</p>
<p>echo "<a href=\"".get_pretty_url($list[$i]['bo_table'], $list[$i]['wr_id'])."\"> ";</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 {$add_where} order by wr_num limit 0, {$rows} ";
echo $sql;
이렇게 하고 latest_all 실행 시킨 페이지에서 새로고침 해보세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인