테스트 사이트 - 개발 중인 베타 버전입니다

최신글 특정단어만 출력방법좀 부탁드립니다 채택완료

하루야채 10년 전 조회 3,708

아래 소스를 적용하면 카테고리까지만 검색이되는되요 

카테고리에 특정단어 [예] 그누보드 검색까지되게 할수있나요 

 

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); */

 

 

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

답변 1개

채택된 답변
+20 포인트
y
10년 전

if ($ca_name) $where .= " and ca_name LIKE '%$ca_name%'"; 

로그인 후 평가할 수 있습니다

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

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

로그인