최신글에서 원하는 분류만 가져오고 싶습니다.
본문
안녕하세요. 질답과 팁을 찾아보다 해결이 안되어 문의드립니다.
현재 '가나다' 게시판에 분류가 A|B|C|D가 있는데 최신글에서 D를 제외한 최신글을 불러오려고 합니다.
도움 부탁드립니다.
현재 아래와 같이 사용하고 있습니다.
<div class="bo_lst_casel_in">
<?php for ($i=0; $i<count($list); $i++) { ?>
<ul class="bo_lst_in_casel" id="nowin_<?=$i?>">
<?php
$li_thumb2 = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $thumb_w2, $thumb_h2);
$li_noimg2 = "$latest_skin_url/img/noimg.gif";
if($li_thumb2['src']) {
$img_content2 = '<img src="'.$li_thumb2['src'].'" width="'.$thumb_w2.'" height="'.$thumb_h2.'" alt="'.$list[$i]['subject'].'" title="" />';
} else {
$img_content2 = '<img src="'.$li_noimg2.'" width="'.$thumb_w2.'" height="'.$thumb_h2.'" alt="이미지없음" title="" />';
}
//echo "<li class='casel_img'><span>";
//echo "<a href=\"".$list[$i]['href']."\">";
//echo $img_content2; // 썸네일 출력
//echo "</a></span></li>";
echo "<li class='casel_cate'><span>";
if ($list[$i]['ca_name'])
echo "[{$list[$i]['ca_name']}]";
echo "</span></li>";
echo "<li class='casel_tit'><span>";
//echo $list[$i]['icon_reply']." ";
echo "<a href=\"".$list[$i]['href']."\">";
if ($list[$i]['is_notice'])
echo "<strong>".$list[$i]['subject']."</strong>";
else
echo $list[$i]['subject'];
//if ($list[$i]['comment_cnt'])
//echo $list[$i]['comment_cnt'];
echo "</a>";
// if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
// if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
if (isset($list[$i]['icon_new'])) echo " " . $list[$i]['icon_new'];
//if (isset($list[$i]['icon_hot'])) echo " " . $list[$i]['icon_hot'];
//if (isset($list[$i]['icon_file'])) echo " " . $list[$i]['icon_file'];
//if (isset($list[$i]['icon_link'])) echo " " . $list[$i]['icon_link'];
//if (isset($list[$i]['icon_secret'])) echo " " . $list[$i]['icon_secret'];
echo "</span></li>";
// echo $list[$i]['name']
//echo "<li class='casel_name'>".$list[$i]['name']."</li>";
echo "<li class='casel_date'><span>".$list[$i]['wr_name']."</span><span>".$list[$i]['datetime']."</span></li>";
?>
</ul>
<?php } ?>
</div>
</div>
답변 1
특정 분류를 제외한 나머지 글만 최신글로 뽑으려면 스킨파일을 수정하는게 아니라
./lib/latest.lib.php 파일을 수정해야 합니다.
파일 내용에 보면 약 63라인쯤에 아래와 같은 내용이 있습니다.
$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 and ca_name <> 'D' order by wr_num limit 0, {$rows} ";
ca_name <> 'D' => 분류중 'D'가 아닌 자료만 셀렉트라는 뜻이죠.
또는 ca_name != 'D' 또는 ca_name not in ('D) 등 동일합니다.
참고내용 =
위 처럼 latest.lib.php 파일을 수정할경우 모든 최신글에 적용되므로 특정 게시판만 적용할경우에는
function latest 의 함수 전체를 똑같이 복사후 "가나다" 게시판만 셀렉트하여 불러오도록 수정하는게 좋긴 하죠.
$sql = " select * from g5_write_test where wr_is_comment = 0 and ca_name <> 'D' order by wr_num limit 0, 5 ";
이런식으로 셀렉트 할 수 있습니다.
!-->!-->!-->