채택완료

분류별 최신글 뽑기

2014-10-19 (일) 03:13:46 6,263

 <?php echo  latest("basic_gallery", "게시판명", 8, 15, "ca_name='예능'");​?>

 

latest.lib.php 파일보면 옵션이란게 있떤데 그 옵션을 ca_name으로 사용하면 안되나요?

 

|

답변 2개 / 댓글 3개

채택된 답변
+20 포인트

latest.lib.php 하단에 아래처럼 추가해서 넣거나 파일 새로 만들어서 lib 폴더에 넣고 불러오고..

추출은 이런식으로..

<?php echo latest_category("basic", "free", 5, 25, "", "카테고리명");?> 

Copy
// 최신글 카테고리별로 추출 function latest_category($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="", $category=""){     global $g5;  	if (!$skin_dir) $skin_dir = 'basic';     $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;    $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;      $list = array(); 	$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 ca_name = '{$category}' order by wr_num limit 0, {$rows} ";     $result = sql_query($sql);    for ($i=0; $row = sql_fetch_array($result); $i++) {        $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);    } 	ob_start();     include "$latest_skin_path/latest.skin.php";     $content = ob_get_contents();     ob_end_clean();      return $content; }

답변에 대한 댓글 1개

2014-10-20 (월) 20:01:47
아. basic으로 뽑히길래 봣더니 최신글 스킨 문제였습니다 ㅠㅠ 감사합니다

답변에 대한 댓글 2개

2014-10-20 (월) 21:50:52
만약 같은제목이라면 1개만 출력하고자 할때

[code]$sql = " select * from {$tmp_write_table} where ca_name = '{$category}' order by wr_num limit 0, {$rows} "; [/code]

이부분을

[code]$sql = " select * from {$tmp_write_table} where ca_name = '{$category}' group by wr_subject, {$rows} ";[/code]

이와같이 변경하면 제목이 같은경우 1개만 출력되긴하는데 문제가 없을까요?
전 전문가가 아니라서 검증은 새글로 질문해서 고수분들께 체크해보세요.

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