선택한 게시물 메인 최신글에 나오게 채택완료
http://sir.kr/data/editor/2411/33102762_1731045637.7772.png" width="346" />
일반 게시판에 신상품/베스트 버튼 선택하면 메인에 노출되는 형태로 하고 싶어요~
베스트는 되는데 신상품은 안되네요 ㅠㅠ
머가 문제일까요?
write.php
</strong></p>
<p><input type="checkbox" name="wr_5" value="1"<? echo ($wr_5 =='1') ? ' checked="checked"' : '';?>> 신상품
<input type="checkbox" name="wr_6" value="1"<? echo ($wr_6 =='1') ? ' checked="checked"' : '';?>>베스트</p>
<p><strong>
latest.lib.php
</strong></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> $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} ";
$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><strong>
index.php
</strong></p>
<p><h3>베스트</h3>
<?php
echo latest('theme/pic_block', 'product', 4, 23,'','',array('wr_6'=>1)); // 베스트
?></p>
<p><h3>신상품</h3>
<?php
echo latest('theme/pic_block', 'product', 4, 23,'','',array('wr_5'=>1)); // 신상품
?></p>
<p><strong>
답변 4개
똑같은 방법으로 하나는 되고 하나는 안된다면 값이 저장 되었는지 확인해보세요
echo ($wr_5 =='1') ? ' checked~~ <===이렇게 해서는 체크 안됩니다
아래처럼 고치고 체크 되는지 확인하세요
echo ($write['wr_5'] =='1') ? ' checked~~
답변에 대한 댓글 3개
pic_block폴더를 복사해서 pic_block2로 만들고
두번째는 latest('theme/pic_block2' ~~~~ 이렇게 사용하세요
진심으로 감사드립니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
<li class="chk_box form_checkbox">
<input type="checkbox" class="selec_chk" name="wr_5" id="wr_5" value="1"<? echo ($write['wr_5'] =='1') ? ' checked="checked"' : '';?>> <label for="wr_5"><span></span>신상품</label></li>
<li class="chk_box form_checkbox">
<input type="checkbox" class="selec_chk" name="wr_6" id="wr_6" value="1"<? echo ($write['wr_6'] =='1') ? ' checked="checked"' : '';?>><label for="wr_6"><span></span>베스트</label>
</li>
</ul>
체크는 되는데 메인 노출되는건 다 베스트로만 나옵니다 ㅠㅠ