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

게시판 카테고리별 호출 채택완료

qoqofh 5년 전 조회 2,306

지금 이렇게 게시판 글을 메인페이지에 출력하려고 합니다.

 

 

company라는 이름을 가진 게시판에서 방역이라는 카테고리에 포함되어 있는 게시글만 출력해 보력하는데, 나오질 않네요 ㅠㅠ 해결방법이 있을까요?

 

echo latest('theme/basic', 'company', 8, 28); 이렇게하면 출력이 잘되긴하는데 해당 카테고리목록만 출력을 하고 싶은 상태입니다 ㅠ

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

답변 3개

채택된 답변
+20 포인트

latest.lib.php 에 추가

///////////////////////////////// /*   * 카테고리 추가.  *  */ function latest_category($skin_dir='', $bo_table, $rows=10, $subject_len=40, $category='', $cache_time=1, $options='') {     global $g5;     if (!$skin_dir) $skin_dir = 'basic';          if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {         if (G5_IS_MOBILE) {             $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];             if(!is_dir($latest_skin_path))                 $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];                 $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);         } else {             $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];             $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);         }         $skin_dir = $match[1];     } else {         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;         }     }          $caches = false;          if(G5_USE_CACHE) {         $cache_file_name = "latest-{$bo_table}-{$category}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();         $caches = g5_get_cache($cache_file_name);         $cache_list = isset($caches['list']) ? $caches['list'] : array();         g5_latest_cache_data($bo_table, $cache_list);     }          if( $caches === false ){         $list = array();                  $board = get_board_db($bo_table, true);                  $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 and wr_1='{$category}' order by wr_num limit 0, {$rows} ";         $result = sql_query($sql);         for ($i=0; $row = sql_fetch_array($result); $i++) {             try {                 unset($row['wr_password']);     //패스워드 저장 안함( 아예 삭제 )             } catch (Exception $e) {             }             $row['wr_email'] = '';              //이메일 저장 안함             if (strstr($row['wr_option'], 'secret')){           // 비밀글일 경우 내용, 링크, 파일 저장 안함                 $row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';                 $row['file'] = array('count'=>0);             }             $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);                          $list[$i]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "and bf_type between '1' and '3'", true) : array('bf_file'=>'', 'bf_content'=>'');             $list[$i]['bo_table'] = $bo_table;             // 썸네일 추가             if($options && is_string($options)) {                 $options_arr = explode(',', $options);                 $thumb_width = $options_arr[0];                 $thumb_height = $options_arr[1];                 $thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);                 // 이미지 썸네일                 if($thumb['src']) {                     $img_content = ''.$thumb['alt'].'';                     $list[$i]['img_thumbnail'] = ''.$img_content.'';                     // } else {                     //     $img_content = ''.$thumb['alt'].'';                 }             }         }         g5_latest_cache_data($bo_table, $list);                  if(G5_USE_CACHE) {                          $caches = array(                     'list' => $list,                     'bo_subject' => sql_escape_string($bo_subject),             );                          g5_set_cache($cache_file_name, $caches, 3600 * $cache_time);         }     } else {         $list = $cache_list;         $bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';     }          ob_start();     include $latest_skin_path.'/latest.skin.php';     $content = ob_get_contents();     ob_end_clean();          return $content; }

 

////////////////////////////////////////////////////////

 

 

예전에 쓰던건데 wr_1로 분류하셨나보네요.. 전 ca_name으로 썼었는데

저거 그대로 쓰면되거나 조금만 수정하시면 될겁니다..

 

 

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

답변에 대한 댓글 1개

q
qoqofh
5년 전
네 저도 지금 방금 해결했어요 ㅎㅎ 감사합니다 ㅎㅎ

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

답변에 대한 댓글 1개

q
qoqofh
5년 전
select * from g5_write_company where wr_is_comment = 0 AND ca_name = '방역' order by wr_num limit 0, 8


이부분에 대한 결과물이랑 똑같이 나오는데... 현재 게시물은 있는데 게시물이 없다고 합니다.

오타부분도 없는데 출력이 되질 않네요 ㅠㅠ

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

J
5년 전

그누보드 기본 함수에서는 카테고리 출력을 지원하지 않습니다.

원하는 카테고리나, 질문자님의 wr_1 처럼 추가 필드를 활용한 값을 노출하시려면

latest.lib 파일을 직접 수정하셔야 합니다.

 

최신글 관련 팁을 참조하시면 도움이 되실 듯 싶습니다.

https://sir.kr/g5_tip?sca=&sfl=wr_subject%7C%7Cwr_content&stx=%EC%B9%B4%ED%85%8C%EA%B3%A0%EB%A6%AC+%EC%B5%9C%EC%8B%A0%EA%B8%80">https://sir.kr/g5_tip?sca=&sfl=wr_subject%7C%7Cwr_content&stx=%EC%B9%B4%ED%85%8C%EA%B3%A0%EB%A6%AC+%EC%B5%9C%EC%8B%A0%EA%B8%80

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

답변에 대한 댓글 1개

q
qoqofh
5년 전
select * from g5_write_company where wr_is_comment = 0 AND ca_name = '방역' order by wr_num limit 0, 8


이부분에 대한 결과물이랑 똑같이 나오는데... 현재 게시물은 있는데 게시물이 없다고 합니다.

오타부분도 없는데 출력이 되질 않네요 ㅠㅠ

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

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

로그인