O

카테고리별 최신글 뽑아오기

· 2010-08-11 (수) 14:47:32 · 11299 · 6

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

// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
     global $g4;
    
     $a = explode("|", $bo_table);
     $bo_table = $a[0];
     $ca_name = $a[1];
    
     $latest_skin_path = "$g4[path]/skin/latest";
     $latest_skin_path .= $skin_dir ? "/$skin_dir" : "/basic";
    
     $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
     $board = sql_fetch($sql);
    
     $tmp_write_table = $g4['write_prefix'].$bo_table;
     $where = "where wr_is_comment=0";
     if ($ca_name) $where .= " and ca_name='$ca_name'";
     $sql = " select * from $tmp_write_table $where order by wr_num limit 0, $rows ";
    
     $result = sql_query($sql);
     $list = array();
     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;
}

/* 사용 예
include("$g4[path]/lib/latest.lib.php");
echo latest("basic", "community|freeboard", 10); // 보드명|카테고리명
// echo latest("basic", "community", 10); // 카테고리 없이 사용

카테고리별 최신글 요청이 많아서 따로 함수를 만들어 썼었는데
latest.lib.php를 조금만 수정하면 쉽게 구현이 가능하더군요.
위 소스를 lib/latest.lib.php에 덮어씌우면 됩니다.

그누 소스를 건들기 찜찜하신 분들은
lib/latest2.lib.php로 저장하고
latest.lib.php대신 latest2.lib.php를 인클루드 해서 쓰면 되겠죠.

include("$g4[path]/lib/latest2.lib.php");
echo latest("basic", "community|freeboard", 10);
*/

|

댓글 6개

이런식으로 카테고리 최신글을 뽑고 카테고리 베스트글은 어케 뽑아야 하나요
이것 갤러리 게시판 도 카테고리별 최신글 뽑기 가능한가요?
찾고있던건데~ 감사드립니다~ ^^
완전 감사합니다. 찾던중에 바로 즐찾 합니다~
댓글을 작성하시려면 로그인이 필요합니다.

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
10-08-17 조회 5,383
10-08-16 조회 6,588
10-08-16 조회 4,297
10-08-15 조회 4,262
10-08-15 조회 3,664
10-08-15 조회 4,540
10-08-14 조회 3,703
10-08-12 조회 1.3만
10-08-11 조회 1.1만
10-08-08 조회 6,081
10-08-06 조회 4,918
10-08-04 조회 4,620
10-08-03 조회 4,914
10-07-31 조회 4,752
10-07-30 조회 4.8만
10-07-30 조회 1.5만
10-07-30 조회 1.1만
10-07-29 조회 6,883
10-07-29 조회 6,615
10-07-27 조회 4,761