최신글에 공지 사항만 불러오려면 정보
최신글에 공지 사항만 불러오려면
본문
안녕하세요.
공지사항만 최신글형태로 불러 오려면 어떻게 해야 하죠?
1. 지정된 게시판에서 공지사항만 뽑아오는 방법
2. 지정한 여러게시판에서 공지글들을 뽑아 오는 방법
3. 지정한 그룹에서 공지사항들만 뽑아 오는 방법
4. 전체게시판에서 공지사항만 최신글로 뽑아오는 방법
이와같이 4가지 방향에서 공지사항을 불러오는 방법들이 있겠습니다.
지정된 게시판하나에서만이라도 불러오는 방법이라도 좋으니까요
공지로 정한 글을 뽑아 오는 방법 좀 알려 주세요.
검색을 해도 잘 못찾고 있습니다.
늘 행복하세요. ^^
공지사항만 최신글형태로 불러 오려면 어떻게 해야 하죠?
1. 지정된 게시판에서 공지사항만 뽑아오는 방법
2. 지정한 여러게시판에서 공지글들을 뽑아 오는 방법
3. 지정한 그룹에서 공지사항들만 뽑아 오는 방법
4. 전체게시판에서 공지사항만 최신글로 뽑아오는 방법
이와같이 4가지 방향에서 공지사항을 불러오는 방법들이 있겠습니다.
지정된 게시판하나에서만이라도 불러오는 방법이라도 좋으니까요
공지로 정한 글을 뽑아 오는 방법 좀 알려 주세요.
검색을 해도 잘 못찾고 있습니다.
늘 행복하세요. ^^
댓글 전체


제가 그것을 여러번 적용해 보려고 시도하다가 도저히 안 되어 이곳에 질문올리게 되었어요
저는 엑스엠엘님이 가르쳐 주신 것을 아래와 같이 이해 하였어요.
1. 호출방법
<?php echo latest_notice( 'basic', array( 'a','b','c'), 10, 50); ?>
예) <?php echo latest_notice( '최신글스킨', array( '게시판명','게시판명','게시판명'), 칸수, 글자수); ?>
실적용예) <?php echo latest_notice( 'line', array( '1_1','1_2','1_3'), 10, 50); ?>
2.lib폴더에
latest_notice.php를 만들어서 넣어라
latest_notice.php 파일안에는 아래의 소스를 적어 넣을 것
<?php
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function quoting(&$item1, $key) { $item1 = "'$item1'"; }
function latest_notice($skin_dir="", $bo_tables, $rows=10, $subject_len=40, $options="") {
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
if( !is_array( $bo_tables)) return 'A second parameter error:bo_tables should be an array.';
array_walk( $bo_tables , 'quoting');
$bo_tables_cond= implode(',', $bo_tables);
$notice_res= sql_query( "select bo_table, bo_notice from {$g4['board_table']} where bo_table in ( $bo_tables_cond ) " );
$notice_wr_id_cond=array();
$notice_bo_tables=array();
while( $row= sql_fetch_array( $notice_res)) {
$this_notice= trim($row['bo_notice']);
if( empty( $this_notice)) continue;
$notice_wr_id_cond[]= implode( ',', split("\n", $this_notice));
$notice_bo_tables[]= $row['bo_table'];
}
$sqls= array();
foreach( $notice_bo_tables as $idx => $notice_bo_table) {
$sqls[]= " select wr_id , wr_subject from {$g4['write_prefix']}$notice_bo_table where wr_id in ( {$notice_wr_id_cond[$idx]} )";
}
$list = array();
$result = sql_query( implode( ' union all ', $sqls));
for ($i=0; ($row = sql_fetch_array($result)) && $i < $rows; $i++)
$list[$i] = get_list($row, array( 'bo_table'=>$notice_bo_table), $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
이상이 맞는지요?
저는 이렇게 했는데 전혀 안나타나고 오류가 납니다.
아무래도 제가 뭔가를 잘 못한 것 같은데
뭐이를 잘 못했는지는 잘몰라서 고생중입니다.
조언 부탁올립니다.
늘 행복하세요. ^^
저는 엑스엠엘님이 가르쳐 주신 것을 아래와 같이 이해 하였어요.
1. 호출방법
<?php echo latest_notice( 'basic', array( 'a','b','c'), 10, 50); ?>
예) <?php echo latest_notice( '최신글스킨', array( '게시판명','게시판명','게시판명'), 칸수, 글자수); ?>
실적용예) <?php echo latest_notice( 'line', array( '1_1','1_2','1_3'), 10, 50); ?>
2.lib폴더에
latest_notice.php를 만들어서 넣어라
latest_notice.php 파일안에는 아래의 소스를 적어 넣을 것
<?php
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function quoting(&$item1, $key) { $item1 = "'$item1'"; }
function latest_notice($skin_dir="", $bo_tables, $rows=10, $subject_len=40, $options="") {
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
if( !is_array( $bo_tables)) return 'A second parameter error:bo_tables should be an array.';
array_walk( $bo_tables , 'quoting');
$bo_tables_cond= implode(',', $bo_tables);
$notice_res= sql_query( "select bo_table, bo_notice from {$g4['board_table']} where bo_table in ( $bo_tables_cond ) " );
$notice_wr_id_cond=array();
$notice_bo_tables=array();
while( $row= sql_fetch_array( $notice_res)) {
$this_notice= trim($row['bo_notice']);
if( empty( $this_notice)) continue;
$notice_wr_id_cond[]= implode( ',', split("\n", $this_notice));
$notice_bo_tables[]= $row['bo_table'];
}
$sqls= array();
foreach( $notice_bo_tables as $idx => $notice_bo_table) {
$sqls[]= " select wr_id , wr_subject from {$g4['write_prefix']}$notice_bo_table where wr_id in ( {$notice_wr_id_cond[$idx]} )";
}
$list = array();
$result = sql_query( implode( ' union all ', $sqls));
for ($i=0; ($row = sql_fetch_array($result)) && $i < $rows; $i++)
$list[$i] = get_list($row, array( 'bo_table'=>$notice_bo_table), $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
이상이 맞는지요?
저는 이렇게 했는데 전혀 안나타나고 오류가 납니다.
아무래도 제가 뭔가를 잘 못한 것 같은데
뭐이를 잘 못했는지는 잘몰라서 고생중입니다.
조언 부탁올립니다.
늘 행복하세요. ^^