각 게시판에서 최신글 하나씩만 불러오기 정보
그누호환 각 게시판에서 최신글 하나씩만 불러오기관련링크
본문
그누보드 기본으로 되어 있는 최근 게시물 응용입니다..^^
lib/developer.lib.php파일 제일 하단에 아래소스 추가합니다.
여기서 부터-----------------------------------------------------------------
// 최신글 추출
function list_new($skin_dir='', $bo_table, $rows=10, $len=40)
{
global $latest_skin, $cfg;
// 스킨디렉토리값이 넘어왔다면
if ($skin_dir) {
$latest_skin = "./$cfg[bbs_dir]/skin/latest/$skin_dir";
}
$sql = " select * from $cfg[table_board] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
$sql = " select a.*, mb_open
from {$cfg[write_table_prefix]}{$bo_table} a
left join $cfg[table_member] b on (b.mb_id = a.mb_id)
where a.wr_comment = 0
order by a.wr_id desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;
$list[$i][href] = "./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage], $row[mb_open]);
$list[$i][subject] = conv_subject($row[wr_subject], $len,"…");
$list[$i][content] = get_text($row[wr_content]);
$list[$i][date] = substr($row[wr_datetime],2,8);
$list[$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
for ($k=1; $k<=$cfg[file_count]; $k++) {
if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
}
}
for ($k=1; $k<=$cfg[link_count]; $k++) {
if ($row["wr_link".$k]) {
$link[$i]["link".$k] = set_http(get_text(cut_str($row["wr_link".$k], 255)));
$link[$i]["link_href".$k] = "./?doc=$cfg[bbs_dir]/gblink.php&$qstr&wr_id=$row[wr_id]&index=$k";
}
}
}
mysql_free_result($result);
for ($i=0; $i<count($list); $i++) {?>
<table align=center border=0 width=100% cellpadding=0 cellspacing=1>
<tr onMouseOver=this.style.backgroundColor='#fafafa' onMouseOut=this.style.backgroundColor=''>
<td height=20> <a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><?=$list[$i][subject]?></a> <?=$list[$i][commentcnt]?> <?=$list[$i][icon_new]?></td>
<td width=70 height=20><?=$list[$i][date]?></td>
</tr><tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
</table>
<?}}?>
여기 까지---------------------------------------------------------------------
그리고 아래소스 복사 이름.php로 저장하여
http://URL/gnu/?doc=이름.php 호출하여 사용하시던가
최신글 넣고싶은 곳에 아래소스 복사하여 넣어셔도 되고
저장 파일을 인크르트 하셔도 됩니다
<?
include "./이름.php";
?>
그리고 미리보기는 각 게시판에서 최신글 3개씩을 불러왔습니다.
list_new('', $row[bo_table], 1(각 게시판 최신글 리스트수), 30);
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
define("_DOCTYPE_", "STYLE");
$html_title = "최신글 리스트";
include "./lib/latest.lib.php";
include "./$cfg[bbs_dir]/gblayer.php";
?>
<table align="center" border="0" width="100%">
<tr>
<td align="center" width="100%" height="200">
<table align="center" width=100% cellpadding=0 cellspacing=1>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr><td class='subject subjectbg ht arial' align=center>최신글 리스트</td></tr>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr></table>
<?
// 최신글 시작
$sql = " select bo_table from $cfg[table_board] order by gr_id, bo_table ";
$result = sql_query($sql);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
list_new('', $row[bo_table], 1, 30);
// 최신글 끝
}
?>
</td>
</tr>
</table>
lib/developer.lib.php파일 제일 하단에 아래소스 추가합니다.
여기서 부터-----------------------------------------------------------------
// 최신글 추출
function list_new($skin_dir='', $bo_table, $rows=10, $len=40)
{
global $latest_skin, $cfg;
// 스킨디렉토리값이 넘어왔다면
if ($skin_dir) {
$latest_skin = "./$cfg[bbs_dir]/skin/latest/$skin_dir";
}
$sql = " select * from $cfg[table_board] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
$sql = " select a.*, mb_open
from {$cfg[write_table_prefix]}{$bo_table} a
left join $cfg[table_member] b on (b.mb_id = a.mb_id)
where a.wr_comment = 0
order by a.wr_id desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;
$list[$i][href] = "./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage], $row[mb_open]);
$list[$i][subject] = conv_subject($row[wr_subject], $len,"…");
$list[$i][content] = get_text($row[wr_content]);
$list[$i][date] = substr($row[wr_datetime],2,8);
$list[$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
for ($k=1; $k<=$cfg[file_count]; $k++) {
if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
}
}
for ($k=1; $k<=$cfg[link_count]; $k++) {
if ($row["wr_link".$k]) {
$link[$i]["link".$k] = set_http(get_text(cut_str($row["wr_link".$k], 255)));
$link[$i]["link_href".$k] = "./?doc=$cfg[bbs_dir]/gblink.php&$qstr&wr_id=$row[wr_id]&index=$k";
}
}
}
mysql_free_result($result);
for ($i=0; $i<count($list); $i++) {?>
<table align=center border=0 width=100% cellpadding=0 cellspacing=1>
<tr onMouseOver=this.style.backgroundColor='#fafafa' onMouseOut=this.style.backgroundColor=''>
<td height=20> <a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><?=$list[$i][subject]?></a> <?=$list[$i][commentcnt]?> <?=$list[$i][icon_new]?></td>
<td width=70 height=20><?=$list[$i][date]?></td>
</tr><tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
</table>
<?}}?>
여기 까지---------------------------------------------------------------------
그리고 아래소스 복사 이름.php로 저장하여
http://URL/gnu/?doc=이름.php 호출하여 사용하시던가
최신글 넣고싶은 곳에 아래소스 복사하여 넣어셔도 되고
저장 파일을 인크르트 하셔도 됩니다
<?
include "./이름.php";
?>
그리고 미리보기는 각 게시판에서 최신글 3개씩을 불러왔습니다.
list_new('', $row[bo_table], 1(각 게시판 최신글 리스트수), 30);
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
define("_DOCTYPE_", "STYLE");
$html_title = "최신글 리스트";
include "./lib/latest.lib.php";
include "./$cfg[bbs_dir]/gblayer.php";
?>
<table align="center" border="0" width="100%">
<tr>
<td align="center" width="100%" height="200">
<table align="center" width=100% cellpadding=0 cellspacing=1>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr><td class='subject subjectbg ht arial' align=center>최신글 리스트</td></tr>
<tr><td height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr></table>
<?
// 최신글 시작
$sql = " select bo_table from $cfg[table_board] order by gr_id, bo_table ";
$result = sql_query($sql);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
list_new('', $row[bo_table], 1, 30);
// 최신글 끝
}
?>
</td>
</tr>
</table>
추천
0
0
댓글 전체