채택완료

최신 글 질문 드립니다.

2015-12-28 (월) 17:50:58 4,210

그룹을 이용하여 각 게시판에서 최신글을 하나씩 가져오도록 만들었습니다.(이미지 갤러리 형태)

질문. 혹시 게시판에서 가져오는 글을 최신글이 아니라 몇번째 글 인지 게시판마다 글의 순서를 각각 지정할 수 있을까요?

아래 내용은 사용한 소스 코드 입니다.

제작의뢰로 가라 할것 같은데 혹시나 해서 올려 봅니다 ㅠ.ㅠ

latest.skin 파일
Copy
<?php for ($i=0; $i<count($list); $i++) { ?>                   <a href="<?php echo $list[$i]['href'] ?>" class="slide">       <?php                       $thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $thumb_width, $thumb_height);       if($thumb['src']) {        $img_content = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';       } else {         $img_content = 'NO IMAGE';       }                       echo $img_content;       echo "<span>".$list[$i]['subject']."</span>";                                ?>                 </a>                <?php } ?>
latest_group.lib  파일
Copy
<?phpif (!defined('_GNUBOARD_')) exit;
// 최신글 추출// $cache_time 캐시 갱신시간function latest_group_line($skin_dir="", $gr_id, $rows=10, $eachrows=1, $subject_len=40, $no_table="", $cache_time=1, $category="", $orderby="" ){ global $g5;    //static $css = array();     if (!$skin_dir) $skin_dir = 'basic';
    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;    }     $cache_fwrite = false;    if(G5_USE_CACHE) {  //$cache_file = G5_DATA_PATH."/cache/latest-{$gr_id}-{$skin_dir}-{$rows}-{$subject_len}.php";        $cache_file = G5_DATA_PATH."/cache/latest-{$gr_id}-{$skin_dir}-{$rows}-{$subject_len}.php";
        if(!file_exists($cache_file)) {            $cache_fwrite = true;        } else {            if($cache_time > 0) {                $filetime = filemtime($cache_file);                if($filetime && $filetime < (G5_SERVER_TIME - 600 * $cache_time)) {                    @unlink($cache_file);                    $cache_fwrite = true;                }            }
            if(!$cache_fwrite)                include($cache_file);        }    }      if(!G5_USE_CACHE || $cache_fwrite) {  //if (!G5_USE_CACHE || !file_exists($cache_file)) {   $list = array();    $limitrows = $eachrows;    $sqlgroup = " select bo_table, bo_subject, bo_9 from {$g5['board_table']} where gr_id = '$gr_id' $sqls ";
  /**** 목록에서 제외시킬 테이블들 { ***/  if ($no_table) {   $t_flag = serialize($no_table);   if ($t_flag[0] == "a") { //Array이면    for ($ic=0; $ic<count($no_table); $ic++) {     $sqlgroup .= " and bo_table != '$no_table[$ic]' ";    }   } else if ($t_flag[0] == "s") { //String이면    $sqlgroup .= " and bo_table != '$no_table' ";   }  } 
  $sqlgroup .= " and bo_use_search=1 order by bo_order ";  $rsgroup = sql_query($sqlgroup);  /**** 목록에서 제외시킬 테이블들 } ***/     for ($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) {   $bo_table = $rowgroup[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 = "select * from {$tmp_write_table} where wr_is_comment = 0 ";   // $sql .= "and wr_datetime > ( now() - interval 512 hour) ";   $sql .= (!$category) ? "" : " and ca_name = '$category' ";   $sql .= (!$orderby) ? "  order by wr_id desc " : "  order by wr_id desc ";   $sql .= " limit $limitrows";   // 옵션에 따라 정렬 } //   $result = sql_query($sql);   for ($i=0; $row = sql_fetch_array($result); $i++, $k++) {    if(!$orderby) $op_list[$k] = $row[wr_datetime];    else  {     $op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]);     $op_list[$k] .= $row[wr_datetime];    }
    $list[$k] = get_list($row, $board, $latest_skin_url, $subject_len);
    $list[$k][bo_table] = $board[bo_table];    $list[$k][bo_subject] = $board[bo_subject];
    $list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len);   }  }    if($cache_fwrite) {   $handle = fopen($cache_file, 'w');            $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".$bo_subject."';\n\$list=".var_export($list, true)."?>";      fwrite($handle, $cache_content);   fclose($handle);    } }     /*    // 같은 스킨은 .css 를 한번만 호출한다.    if (!in_array($skin_dir, $css) && is_file($latest_skin_path.'/style.css')) {        echo '<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">';        $css[] = $skin_dir;    }    */  if($k>0) array_multisort($op_list, SORT_DESC, $list); if($k>$rows) array_splice($list, $rows);
 ob_start();    include $latest_skin_path.'/latest.skin.php'; $content = ob_get_contents(); ob_end_clean();  return $content;}?>

이용해서 사용 했습니다.

답변 1개 / 댓글 1개

채택된 답변
+20 포인트
2015-12-28 (월) 23:59:58

제작의뢰로 가셔야 할 것 같네요..

힌트를 드리면 제일 간단한 방법으론

각 게시판에서 몇번째 글을 가져올지 배열에 넣어두고

latest_group_line 함 수 에서 해당 그룹에 해당하는 게시판을 돌면서 최신글을 select 해올때

limit 을 걸어서 해주시면 될 듯 합니다.

답변에 대한 댓글 1개

지지 쳐야 되겠네요 ㅎㅎ;
답변 감사합니다.

답변을 작성하려면 로그인이 필요합니다.