최신글 소스 도움을 부탁드립니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

최신글 소스 도움을 부탁드립니다. 정보

최신글 소스 도움을 부탁드립니다.

본문

<?
if (!defined('_GNUBOARD_')) exit;


// 최신글 추출
function arr_new($skin_dir="", $board_arr=array(), $rows=10, $subject_len=40, $options="")
{
    global $g4;

if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();
    $board_list = array();

    //검색조건
    if(count($board_arr)>0){
    $qry_bo_search=" bo_table in(";
    for($i=0; $i<count($board_arr); $i++) {
    $bo_table=$board_arr[$i];
    $qry_bo_search .= "'$bo_table'";
    if($i<count($board_arr)-1) $qry_bo_search .= ", ";
    }
$qry_bo_search .= ")";
} else {
$qry_bo_search="(1)";
}

//echo $qry_bo_search;

//new에서 해당되는 게시판의 최신글 뽑아오기
    $sql = "select bo_table, wr_id from $g4[board_new_table]
where wr_id = wr_parent and $qry_bo_search order by bn_datetime desc LIMIT 0,$rows";

$result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++) {
    $bo_table=$row[bo_table];
    $write_table=$g4['write_prefix'].$bo_table;

    $board_sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board_list[$i]=sql_fetch($board_sql);

    $list[$i]=sql_fetch("select * from $write_table where wr_id='$row[wr_id]' ");

    //기타 설정
    if ($subject_len)
        $list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $subject_len, "…");
    else
        $list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $board_list[$i]['bo_subject_len'], "…");

    $list[$i][href]="$g4[bbs_path]/board.php?bo_table={$board_list[$i][bo_table]}&wr_id={$list[$i][wr_id]}".$qstr;

    //$list[$i]['is_notice'] = preg_match("/[^0-9]{0,1}{$list[$i]['wr_id']}[\r]{0,1}/", $board_list[$i]['bo_notice']);
    $list[$i]['is_notice']=false;
    $arr_notice = split("\n", trim($board_list[$i]['bo_notice']));
    if(in_array($list[$i]['wr_id'], $arr_notice)) $list[$i]['is_notice']=true;

    echo "<!--".$board_list[$i]['bo_table']."/".$board_list[$i]['bo_notice']."-->";

    $list[$i]['icon_new'] = "";
    if ($list[$i]['wr_datetime'] >= date("Y-m-d H:i:s", $g4['server_time'] - ($board_list[$i]['bo_new'] * 3600)))
        $list[$i]['icon_new'] = "<img src='$latest_skin_path/img/icon_new.gif' align='absmiddle'>";

        $list[$i]['comment_cnt'] = "";
    if ($list[$i]['wr_comment'])
        $list[$i]['comment_cnt'] = "({$list[$i][wr_comment]})";

if ($board_list[$i]['bo_use_comment'])
        $list[$i]['comment_href'] = "javascript:win_comment('$g4[bbs_path]/board.php?bo_table=$board_list[$i][bo_table]&wr_id=$list[$i][wr_id]&cwin=1');";
    else
        $list[$i]['comment_href'] = $list[$i]['href'];

    $list[$i]['icon_secret'] = "";
    if (strstr($list[$i]['wr_option'], "secret"))
        $list[$i]['icon_secret'] = "<img src='$latest_skin_path/img/icon_secret.gif' align='absmiddle'>";

    $list[$i]['datetime'] = substr($list[$i]['wr_datetime'],0,10);
    $list[$i]['datetime2'] = $list[$i]['wr_datetime'];

    if ($list[$i]['datetime'] == $g4['time_ymd'])
        $list[$i]['datetime2'] = substr($list[$i]['datetime2'],11,5);
    else
        $list[$i]['datetime2'] = substr($list[$i]['datetime2'],5,5);

    }

    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>

위 소스는 내가 원하는게시판의 최신글을 불러오는 소스인데요.
일정 날짜가 지나면 게시물이 사라지는 현상이 나타납니다.
소스 어느 부분이 날짜와 연관이 있는 부분인지 초보가 아무리 지우고 더하고 해봐도 안되네요.

가장 마지막으로 등록된 몇개의 글이 계속 나타나게 할려면 어디를 수정해야 하는지 회원님들의 도움을 부탁드립니다.
꾸벅

댓글 전체

$g4[board_new_table] 테이블에서 읽어와서 그런듯 하네요
관리자메뉴 기본설정에 보면 최근게시물 삭제가 30일로 되어 있는데 요걸 수정하여 보시거나
sql에서 new_table 이 아니라 각각의 해당 테이블에서 읽어오시는것이....
게시판 설정에 new 이미지 해서 설정해놓는 시간안에 게시물들 출력되게 해놓은거 같은데....
$board_arr에서 값 넘어 오는게....;;;
아마 $qry_bo_search에서 새글 부분 짤라내는거 같은데...

//new에서 해당되는 게시판의 최신글 뽑아오기
    $sql = "select bo_table, wr_id from $g4[board_new_table]
where wr_id = wr_parent ||and $qry_bo_search|| order by bn_datetime desc LIMIT 0,$rows";

||...||이부분 삭제하고 해보세요...안될수도....;;;;
대충 훑어 봐서리...;;;
두 분 답변 감사드립니다.
까까님의 답변대로 해보니까 제가 설정 해 놓은 특정게시판이 아닌 전체 게시물에서 최신글을 불러오는 현상이 나오네요.
그리고 뷰리드님 말씀대로 기본설정에서 삭제 기간은 최대로 늘려보아도 변동은 없습니다.;;
더 해보야겠네요
답변 감사드립니다.
뷰리드님 말씀대로 최근게시물 테이블은 30일이 지나면 삭제되도록 기본설정이 되어있을 것입니다.
그걸 늘려주시면 지금부터 등록되는 글들이 안 없어질 것이고 이미 없어진 글들은 어쩔 수가 없을 것입니다.

$bo_arr = array("bo1", "bo2", "bo3");
foreach($bo_arr as $bo) {
  $query = sql_query("select * from `$g4[write_prefix]$bo` order by wr_datetime desc LIMIT 10");
  while($row = sql_fetch_array($query)) {
    $list[] = $row;
  }
}
usort($list, "usorter");
function usorter($a, $b) {
  if($a[wr_datetime] < $b[wr_datetime]) return 1;
  else return -1;
}

이런 식으로 write 테이블에서 직접 가져와서 소팅해주는 건 어떨까요?
말러83 님 답변 감사 드립니다.
저는 소스를 변경하면 이전 게시물도 나오는줄 알았습니다.
근데 없어진 게시물은 어쩔수 없나보군요.
일단 기본설정에서 날짜를 1000일로 넉넉하게 잡아두었습니다.^^
알려주신 소스는 적용해 보겠습니다.
감사합니다.
꾸벅
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT