[재질문] 게시판 추출 할때 전체 게시판일경우 게시판 하나만하는법 채택완료
질문내용:
지금은 소스상 모든 게시판에서 추출해서 가져오는 듯하고 제가 원하는 건
test 라는 게시판 하나만 리스트에 띄우고 싶습니다....
https://sir.kr/bbs/board.php?bo_table=g5_skin&wr_id=3873&page=0&posting=ok&sca=&sfl=&stx=&sst=&sod=&spt=0&page=0" target="_blank">https://sir.kr/bbs/board.php?bo_table=g5_skin&wr_id=3873&page=0&posting=ok&sca=&sfl=&stx=&sst=&sod=&spt=0&page=0
제가 참고한 소스 입니다.
lib/latest_popular.lib.php 파일 입니다.
<?php
if (!defined('_GNUBOARD_')) exit;
// 인기글 추출
// $cache_time 캐시 갱신시간
function latest_popular($bo_table, $rows=10, $subject_len=40, $term='', $options='')
{
global $g5;
switch($term){
case '일간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24); break;
case '주간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*7); break;
case '월간': $term_time = date("Y-m-d H:i:s", G5_SERVER_TIME-3600*24*30); break;
}
$list = array();
if($bo_table){ //각 게시판 출력
$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_between = " wr_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 and {$sql_between} order by {$options} 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);
}
}else{ //전체 게시판 출력
$sql_between = " a.bn_datetime between '$term_time' and '".G5_TIME_YMDHIS."' ";
$sql_common = " from {$g5['board_new_table']} a, {$g5['board_table']} b where a.bo_table = b.bo_table and b.bo_use_search = 1 and a.wr_id = a.wr_parent and {$sql_between} ";
$sql_order = " order by a.bn_datetime desc ";
$sql = " select a.*, count(b.bo_subject) as cnt {$sql_common} {$sql_order} limit 0, {$rows} ";
$row = sql_fetch($sql);
if($row['cnt'] > 0){
$sql = " select a.*, b.bo_subject {$sql_common} {$sql_order} limit 0, {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++){
$tmp_write_table = $g5['write_prefix'].$row['bo_table'];
$bo_table = $row['bo_table'];
if($i > 0)
$sql2 .= " union ";
$sql2 .= "(select '{$bo_table}' as bo_table, wr_id, wr_subject, wr_hit, wr_good from {$tmp_write_table} where wr_datetime between '{$term_time}' and '".G5_TIME_YMDHIS."') ";
}
$sql2 .= " order by ".$options." limit 0, 10";
$result2 = sql_query($sql2);
for ($i=0; $row2 = sql_fetch_array($result2); $i++){
$list[$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$row2['bo_table'].'&wr_id='.$row2['wr_id'];
$list[$i]['subject'] = $row2['wr_subject'];
}
}
}
ob_start();
?>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-1" checked class="tab-switch">
<label for="tab-1" class="tab-label" href="#" jquery16408452460570924265=1>일간 조회수</label>
<div class="tab-content"><?php echo latest_popular($bo_table, 10, 40, '일간', 'wr_hit desc'); ?></div>
</div>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-2" class="tab-switch">
<label for="tab-2" class="tab-label" href="#" jquery16408452460570924265=2>일간 추천수</label>
<div class="tab-content"><?php echo latest_popular($bo_table, 10, 40, '일간', 'wr_good desc'); ?></div>
</div>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-3" class="tab-switch">
<label for="tab-3" class="tab-label" href="#" jquery16408452460570924265=3>주간 조회수</label>
<div class="tab-content"><?php echo latest_popular($bo_table, 10, 40, '주간', 'wr_hit desc'); ?></div>
</div>
<div class="tab">
<input type="radio" name="css-tabs" id="tab-4" class="tab-switch">
<label for="tab-4" class="tab-label" href="#" jquery16408452460570924265=4>주간 추천수</label>
<div class="tab-content"><?php echo latest_popular($bo_table, 10, 40, '주간', 'wr_good desc'); ?></div>
</div>
-------------------------------------------------------------------------------------------------
theme/test/mobile/index.php
바로 밑에 보이는게 불러오는 부분입니다. "히트글 순위" 저부분이 제가 불러온 부분입니다.
<!-- 히트글 순위 -->
<?php
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법 : latest(스킨, 게시판아이디, 출력라인, 글자수);
// 테마의 스킨을 사용하려면 theme/basic 과 같이 지정
include_once(G5_LIB_PATH.'/latest_popular.lib.php');
?>
<!-- 배너 최신글 -->
<?php
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법 : latest(스킨, 게시판아이디, 출력라인, 글자수);
// 테마의 스킨을 사용하려면 theme/basic 과 같이 지정
echo latest('theme/about', 'about', 1, 33);
?>
<!-- a메뉴 최신글 -->
<?php
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법 : latest(스킨, 게시판아이디, 출력라인, 글자수);
// 테마의 스킨을 사용하려면 theme/basic 과 같이 지정
echo latest('theme/menu', 'free', 12, 33);
?>
답변 1개
</p>
<p> </p>
<p><!-- 히트글 순위 -->
<?php
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법 : latest(스킨, 게시판아이디, 출력라인, 글자수);
// 테마의 스킨을 사용하려면 theme/basic 과 같이 지정
include_once(G5_LIB_PATH.'/latest_popular.lib.php');
?> </p>
<p> </p>
<p>
코드 지우시고
</p>
<p><?</p>
<p>// latest(테마명,게시판고유명,출력하소싶은 줄수, 해당줄당 끊고싶은 글자수);</p>
<p>echo latest('theme/basic', 'test', 1, 33); </p>
<p>?></p>
<p>
위 설명대로 바꿔 처리하세요.
이미 /latest_popular.lib.php 라이브러리 끌어온 상태일껍니다. 중복등록 필요없구요,
latest('theme/basic', 'test', 1, 33); 문구 자체가 하나의 게시판만 끌어오는겁니다.
해석하면, 테마/베이직으로 test 게시판을 1줄 가져오고 33글자만 출력한다. 입니다.
답변에 대한 댓글 4개
이미 게시판을 사용하고 있다면 불러올 테마는 있을겁니다.
참고로 하단에 적용된 theme/about 나 theme/menu 도 이미 쓰고있는 테마겠지요.
lib 파일은 DB쿼리 적용 후 data 출력 또는 기타 function의 모음이거나 class 파일입니다.
따라서 일반적으로 외부출력 자체를 가지고 있지는 않습니다.
기능자체가 data 가공이 목적입니다. html 파싱이 목적이 아닙니다..
데이터 가공 후 출력은 skin 에서 처리합니다. 따라서 다른 디자인을 원하신다면
원하시는 skin을 제작 후 적용하시면 , lib에 적용해서 출력 됩니다.
* 적용방법 *
1. theme/about 이나 theme/menu 중 하나를 복사해서 theme/새로운스킨 으로 만드세요.
(만약 복사할 스킨이 리스팅 출력의 목적에 맞지않다면,
목적에 맞는 비슷한 스킨을 복사하시거나 제작 하세요.)
2. theme/새로운스킨 을 적용하세요.(외형적인 모양은 외부 스킨에서 적용합니다.)
위 내용을 이해하지 못하신다면 "제작의뢰" 게시판에 의뢰 하시는게 맞습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
테마 자체가 준게 아니라 lib로만 작동하는거라 불가능해요 디자인이 안나와요