★문의☆ 메인 최신글 공지사항 만들기
본문
위의 사진 처럼 게시판의 갯수만큼 공지사항이 떠버립니다.
공지사항 게시판 하나만 메인에 적용하는 방법이 궁금합니다.
index.php는 아래와 같고
<?
include_once("$g4[path]/lib/latest.lib.php");
$g4['title'] = "";
include_once("./_head.php");
?>
<!-- 메인화면 최신글 시작 -->
<table width="100%" cellpadding=0 cellspacing=0><tr><td valign=top>
<?
// 최신글
$sql = " select bo_table, bo_subject from $g4[board_table] order by gr_id, bo_table ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 스킨은 입력하지 않을 경우 관리자 > 환경설정의 최신글 스킨경로를 기본 스킨으로 합니다.
// 사용방법
// latest(스킨, 게시판아이디, 출력라인, 글자수);
echo latest_notice('simple_blue', 'notice', 3 , 60);
echo "<p>\n";
}
?>
</td></tr></table>
<!-- 메인화면 최신글 끝 -->
<?
include_once("./_tail.php");
?>
latest.lib.php 는 아래와 같습니다
<?
?>
// 최신글 추출
function latest_notice($skin_dir="", $bo_table, $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";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
//-- 아래 3줄 변경되었습니다
$arr_notice = preg_replace("/\n/",',', trim($board[bo_notice]));
if(!$arr_notice) $arr_notice=0;
$result = sql_query(" select * from $tmp_write_table where wr_id IN($arr_notice) order by wr_num limit 0, $rows");
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;
}
?>
많은 답변 기다리겠습니다.
-이외에 저희가 노프레임으로 처음 만드는것인데 위작업이 완료되면 메인에 적용하는 방법은 또 어떻게 되는걸까요?
답변 1
// 최신글
//$sql = " select bo_table, bo_subject from $g4[board_table] order by gr_id, bo_table ";
//$result = sql_query($sql);
//for ($i=0; $row=sql_fetch_array($result); $i++) {
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 스킨은 입력하지 않을 경우 관리자 > 환경설정의 최신글 스킨경로를 기본 스킨으로 합니다.
// 사용방법
// latest(스킨, 게시판아이디, 출력라인, 글자수);
echo latest_notice('simple_blue', 'notice', 3 , 60);
//echo "<p>\n";
//}
위의 소스처럼 주석처리하거나 지우시면되요~
!-->