[그누보드]최신글 분류별로 출력하는 방법

2012. 8. 29. 15:48 Web/javascript

몇일간 고민했던 카테고리별 최신글 추출 
lib/latest.lib.php 페이지에 입력

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

// 최신글 추출

function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="", $ca_name="")
{
    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();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
 //함께 출력되는 영역이 있는 경우(서울+부산)
  /*if($bo_table == "notice"){
   if(trim($ca_name) != ""){
    if(trim($ca_name) == "서울"){
  $where_query = "and (ca_name='서울'  or ca_name='부산')";
    }else{
  $where_query = "and ca_name='".$ca_name."' ";
    }
   }else{
    $where_query = "";
   }
  }*/

 if ($ca_name)
  $sql = " select * from $tmp_write_table where wr_is_comment = 0 and ca_name = '$ca_name' order by wr_num limit 0, $rows ";
    else
     $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
 

    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>


---------------------------------------------------------------------------

출력되는 페이지에 입력
<?=latest_ca("latest명", "board명", 5, 40,"","분류명");?>

Copyright © HuckleberryM All Rights Reserved | JB All In One Designed by CMSFactory.NET