특정그룹내 게시판별 공지글만 최신글에 출력하기 정보
특정그룹내 게시판별 공지글만 최신글에 출력하기본문
특정그룹내에서 게시판별로 공지글만 최신글로 출력하기 위해서 아래처럼 했습니다.
1) 불러오기
----------------------------------------------
<?
$gr_id = 'directory';
$latest_skin_name = "la_directory"; // 스킨명지정
$sql = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' order by bo_table ";
$result = sql_query($sql);
$k=0;
echo "<tr valign='top'>";
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$s_table = $row[bo_table]; // 그룹내 게시판을 변수로 저장
if( $s_table == tmd_01b00 || $s_table == tmd_09b01 ) { // 미출력 게시판
} else {
$k=$k+1;
echo "<td>";
// latest_category(스킨명, 테이블명,출력갯수,글자수,옵션(wr_1 or '공지' or '' 설정된 항목만 불러옴)
echo latest($latest_skin_name, $s_table, 5, 15, '');
echo "</td>";
if($k==8) {echo "</tr><tr valign='top'>"; $k=0;} // 가로 칼럼갯수
}
}
2) latest.skin.php 구문...
----------------------------------------------
<? for ($i=0; $i<count($list); $i++) {
if ($list[$i]['is_notice']) { // '공지'에 체크된 게시물만 출력
echo "<a class='ca_list' href='{$list[$i][link_href][1]}' target='_blank'>";
echo "<font color='{$f_color}'>";
echo "{$list[$i][subject]}";
echo "</font></a>";
echo "<br>";
}else{
}
}
?>
[문제]
특정 그룹내 게시판별 최신글을 가져오는데 '공지'글만 최신글로 불러오려고 합니다.
그중에 최신글 출력에서 게시판별로 각각 5개만 출력되게 하려고 위코드를 만들었는데,
최신글 불러오기 화면에서 보면 2개밖에 출력이 되지를 않습니다.
이래저래 다해봤는데 도무지 알수가 없군요.
g4_board 테이블과 연동해야하는거 같은데... 잘 모르겠네요??!!!
어쨋던 최신글 불러오기(1번파일)에서 출력할게시글수를 '5' -> '10' 이런식으로 숫자를 늘려주면
한 5-6개정도가 또 출력됩니다.
뭐가 잘못된것인지요...도움글을 구합니다.
1) 불러오기
----------------------------------------------
<?
$gr_id = 'directory';
$latest_skin_name = "la_directory"; // 스킨명지정
$sql = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' order by bo_table ";
$result = sql_query($sql);
$k=0;
echo "<tr valign='top'>";
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$s_table = $row[bo_table]; // 그룹내 게시판을 변수로 저장
if( $s_table == tmd_01b00 || $s_table == tmd_09b01 ) { // 미출력 게시판
} else {
$k=$k+1;
echo "<td>";
// latest_category(스킨명, 테이블명,출력갯수,글자수,옵션(wr_1 or '공지' or '' 설정된 항목만 불러옴)
echo latest($latest_skin_name, $s_table, 5, 15, '');
echo "</td>";
if($k==8) {echo "</tr><tr valign='top'>"; $k=0;} // 가로 칼럼갯수
}
}
2) latest.skin.php 구문...
----------------------------------------------
<? for ($i=0; $i<count($list); $i++) {
if ($list[$i]['is_notice']) { // '공지'에 체크된 게시물만 출력
echo "<a class='ca_list' href='{$list[$i][link_href][1]}' target='_blank'>";
echo "<font color='{$f_color}'>";
echo "{$list[$i][subject]}";
echo "</font></a>";
echo "<br>";
}else{
}
}
?>
[문제]
특정 그룹내 게시판별 최신글을 가져오는데 '공지'글만 최신글로 불러오려고 합니다.
그중에 최신글 출력에서 게시판별로 각각 5개만 출력되게 하려고 위코드를 만들었는데,
최신글 불러오기 화면에서 보면 2개밖에 출력이 되지를 않습니다.
이래저래 다해봤는데 도무지 알수가 없군요.
g4_board 테이블과 연동해야하는거 같은데... 잘 모르겠네요??!!!
어쨋던 최신글 불러오기(1번파일)에서 출력할게시글수를 '5' -> '10' 이런식으로 숫자를 늘려주면
한 5-6개정도가 또 출력됩니다.
뭐가 잘못된것인지요...도움글을 구합니다.
댓글 전체
현재 1번화일에서 특정 게시물의 갯수(질문하신 분께서 말하신 5 -> 10 이부분)을 뽑아서
2번 화일에서 그중 공지만 출력하고 있는 구조인 것 같은데요..
결국 1번에서 전체 게시글 중 갯수를 뽑았는데 그것을 다시 공지만 출력하다보니 갯수와 원하는 5개가 아니라 2개나 또는 1번의 갯수를 늘리면 그 사아의 공지가 나오는 그런 구조로 된 것 같네요.
1번에서 처음부터 게시글을 뽑는게 아니라 공지만 뽑아오게 해야할 것 같습니다.
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=16131&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15676&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
참고해보시면 될 듯 하네요.
2번 화일에서 그중 공지만 출력하고 있는 구조인 것 같은데요..
결국 1번에서 전체 게시글 중 갯수를 뽑았는데 그것을 다시 공지만 출력하다보니 갯수와 원하는 5개가 아니라 2개나 또는 1번의 갯수를 늘리면 그 사아의 공지가 나오는 그런 구조로 된 것 같네요.
1번에서 처음부터 게시글을 뽑는게 아니라 공지만 뽑아오게 해야할 것 같습니다.
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=16131&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15676&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
참고해보시면 될 듯 하네요.
어제밤 이와 관련해서 거의 모든글을 검색해 봤는데, 일단 링크해주신 글도 참고했었습니다. 특히
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=16131&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
위글이 가장 가까운 내용이지만, 현재로써는 적용이 되질 않습니다.
특정그룹의 모든 게시판별 최신글을 출력하는데에서는 전혀 먹히질 않는군요.
아마도 공지글부분을 저장하는 g4_board 테이블과 연동해야하는 부분인거 같은데 wr_1 필드도 같이 사용하는탓에 쉽게 구현할수가 없네요~~ -_- ;;
http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=16131&sca=&sfl=wr_subject&stx=%B0%F8%C1%F6&sop=and
위글이 가장 가까운 내용이지만, 현재로써는 적용이 되질 않습니다.
특정그룹의 모든 게시판별 최신글을 출력하는데에서는 전혀 먹히질 않는군요.
아마도 공지글부분을 저장하는 g4_board 테이블과 연동해야하는 부분인거 같은데 wr_1 필드도 같이 사용하는탓에 쉽게 구현할수가 없네요~~ -_- ;;
r결국 별도의 lib파일을 하나 만들고서야 대충 해결~ ... 소스를 안건드리고 작업하려니..무지 힘들군요
.
lib/ 아래에 lib/latest1.lib.php 파일을 생성하세요.
<!-- latest1.lib.php 파일에 아래내용을 넣고 저장-->
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest1($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $config;
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]";
$list = array();
$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$arr_notice = split("\n", trim($board[bo_notice]));
if($board[bo_notice] ) // 이렇게 고치니 되네요..참고하세요..
$in_str= implode( ",", $arr_notice);
else $in_str='null';
$tmp_write_table = $g4['write_prefix'] . $bo_table;
$sql = "select * from $tmp_write_table where wr_id in ( $in_str) order by wr_id desc limit 0,$rows";
$result = sql_query($sql);
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;
}
?>
적용은 넣으려는 페이지의 php파일 상단에
<?
$g4_path = "./board";
include_once("_common.php");
include_once("./_common.php");
include_once("$g4[path]/lib/latest.lib.php");
include_once("$g4[path]/lib/latest1.lib.php"); //이걸넣으세요
include_once("$g4[path]/lib/outlogin.lib.php");
?>
이처럼 넣어주시고
적용할 부분에 다가 아래처럼
<?=latest1("basic","notice","6","33","wr_id","notice");?>
이렇게 넣어주시면 제대로 노출됩니다.
<!-- latest1.lib.php 파일에 아래내용을 넣고 저장-->
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest1($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $config;
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]";
$list = array();
$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$arr_notice = split("\n", trim($board[bo_notice]));
if($board[bo_notice] ) // 이렇게 고치니 되네요..참고하세요..
$in_str= implode( ",", $arr_notice);
else $in_str='null';
$tmp_write_table = $g4['write_prefix'] . $bo_table;
$sql = "select * from $tmp_write_table where wr_id in ( $in_str) order by wr_id desc limit 0,$rows";
$result = sql_query($sql);
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;
}
?>
적용은 넣으려는 페이지의 php파일 상단에
<?
$g4_path = "./board";
include_once("_common.php");
include_once("./_common.php");
include_once("$g4[path]/lib/latest.lib.php");
include_once("$g4[path]/lib/latest1.lib.php"); //이걸넣으세요
include_once("$g4[path]/lib/outlogin.lib.php");
?>
이처럼 넣어주시고
적용할 부분에 다가 아래처럼
<?=latest1("basic","notice","6","33","wr_id","notice");?>
이렇게 넣어주시면 제대로 노출됩니다.