초간단 전체게시물-최신글

· 2007-03-05 (월) 16:09:32 · 15739 · 4
latestall.jpg
원하는 게시물 전체에서 최신글을 모아서 보여줍니다.
복잡한 기능없고 초간단입니다. 멋진것을 원하시는 분은 스킵~
초간단이다보니 스크린샷봐서는 테가 안나지만, 확실히 여러게시물중에서 가져오는 것 맞구요.
디자인은 제가 한개 아니라, 홈피 링크는 시키지 않겠습니다. 따라서 스킨을 그대로 쓰지 마시고 이미지를 본인들 홈피에 맞게 바꿔 쓰실걸 강력 권장합니다.

아래, latest_all 함수 만큼은 저의 나름 노우하우가 들어갔습니다. sql의 union을 쓰고, 배열 includetables와 excludetables를 써서 포함하거나 뺄 테이블을 깔끔하게 처리했다고 자부가 되어서 한번 올려봅니다. (비슷한게 이미 올라와 있을까 좀 두렵네요 ^^;)
줄에 거의 제목만 출력되는데, 이것은 다른 정보를 담기엔 너무 지저분해 질거 같아서요. 툴팁에다 그런걸 넣어서 표현하면 좋겠는데, 귀찮아설, 누가 좀 만들어 주심 않될까요? ^^


사용법은 다음과 같습니다.
<? latest_all('latestall', '업데이트', 4,46); ?>
파라메터는 순서대로 : 스킨폴더, 타이틀, Rows, 컬럼글자수

첨부한 latestall.zip을 bbs/skin/latest/ 아래 latestall폴더를 만들어 복사

다음 소스를 적절한 곳에 복사합니다. 저같은 경우는 latest.lib.php에 추가했습니다.

// 모든 테이블에서 최신글 가져오기
// 2007. 3. 5 Programmed by Sean Ki, Based on 'latest' function in latest.skin.php of gnu3
function latest_all($skin_dir='', $title, $rows=10, $len=40)
{
// 2007. 3. 5 특정 테이블만 포함, 또는 제외용 테이블 지정 배열, includetables과 excludetables중 하나만 쓸 수 있음.
$includetables = array("news_info", "story_say", "help_data", "help_qna", "help_tell"); // 이 테이블들만 포함
//excludetables = array("news_info", "news_jikji");// 이 테이블들만 제외
global $latest_skin, $cfg;

$tmp_latest_skin = $latest_skin;

// 스킨디렉토리값이 넘어왔다면
if ($skin_dir) {
$latest_skin = "./bbs/skin/latest/$skin_dir";
}

$sql = " select * from $cfg[table_board] "; // remove this - where bo_table = '$bo_table'
$result = sql_query($sql);

$subsql = "";
while ($row = mysql_fetch_array($result)) {
if (count($includetables) > 0) { // $includetables 배열에 값이 있으면, 여기에 포함된 테이블만 통과 시킨다.
if (!in_array ($row[bo_table], $includetables)) // 배열 중에 없으면 skip
continue;
} else
if (count($excludetables) > 0) {
if (in_array ($row[bo_table], $includetables)) // 배열 중에 있으면 skip
continue;
}


$sql1 = "( select '{$row[bo_subject]}' as bo_subject, '{$row[bo_table]}' as bo_table, wr_id,
wr_parent_id,
mb_id,
wr_name,
wr_email,
wr_homepage,
wr_num,
wr_subject,
wr_content,
wr_comment,
wr_commentcnt,
wr_datetime,
wr_file1,
wr_file2,
wr_link1,
wr_link2,
wr_hit
from {$cfg[write_table_prefix]}{$row[bo_table]}
where wr_comment = 0
order by wr_id desc limit 0, $rows )";
$subsql .= $sql1 . " union ";
}
$subsql = substr($subsql, 0, strlen($subsql) - strlen(" union "));

//$bo = sql_fetch($sql);
//$bo_subject = $bo[bo_subject]; //테이블 제목
$bo_subject = $title;

$sql = " $subsql order by wr_datetime desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;

$list[$i]->bo_subject = $row[bo_subject];
$list[$i]->bo_table = $row[bo_table];

$list[$i][href] = "./?doc=bbs/gnuboard.php&bo_table={$row[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]);
$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=bbs/gblink.php&$qstr&wr_id=$row[wr_id]&index=$k";
}
}
}
mysql_free_result($result);

include "$latest_skin/latest.skin.php";

$latest_skin = $tmp_latest_skin;
}
?>

첨부파일

latestall.jpg (9.7 KB)
0회 2007-03-05 16:09
latestall.zip (1.9 KB) 156회 2007-03-05 16:09
|

댓글 4개

1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

왜이런거죠? 무슨 경로상의 문제라도??
sql 문장에 오류가 있는거 같네요.
좋아요
2008-12-16 (화) 16:51:03
감사합니다
댓글을 작성하시려면 로그인이 필요합니다.

그누3 스킨

740건
+
분류 제목 글쓴이 날짜 조회
알림 10-07-22 조회 8,477
최신글 07-03-05 조회 1.6만
게시판 06-10-09 조회 1.1만
알림 06-09-09 조회 8,748
게시판 06-08-28 조회 1.4만
게시판 06-08-02 조회 1.2만
게시판 06-08-01 조회 1.7만
게시판 06-07-28 조회 9,913
게시판 06-07-25 조회 1.2만
게시판 06-07-11 조회 9,261
게시판 06-06-30 조회 9,651
게시판 06-06-26 조회 8,306
게시판 06-06-25 조회 9,906
회원 06-06-11 조회 9,463
게시판 06-05-24 조회 9,626