[root]님의 카테고리별 최신글을 보면서 정보
그누보드 [root]님의 카테고리별 최신글을 보면서관련링크
본문
root 님의 카테고리별최신글을 응용하고자 해도 쉽지않군요.
고수님들의 조언을 부탁드립니다.
링크1이 루트님의 글입니다.
http://sir.co.kr/?doc=bbs/gblink.php&bo_table=qa&wr_id=23375&index=1
루트님의 말씀대로 아래부분을 디벨롭.리브에 넣었습니다.
------ 아래 시작
// description : 카테고리별 최신글 추출
// created by : root(http://www.threes.org
// version : 1.0
// created : 2003.12.27
// usage :
// latest_cat('byflower', 'bwork', '10', '20', '50', '1,2,3,4');
// latest_cat('byflower', 'bwork', '10', '10', '50', '');
// sample :
// http://threes.org/gnu3/?doc=main/byflower.php
// http://www.sir.co.kr/?doc=bbs/gnuboard.php&bo_table=tiptech&sselect=&stext=§ion=&page=1&wr_id=2729
function latest_cat($skin_dir='', $bo_table, $rows=10, $title_len=40, $content_len=50, $wherecaid)
{
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] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
// category list
$ca_sql = " select * from {$cfg[write_table_prefix]}{$bo_table}_cat ";
if($wherecaid) $ca_sql .= " where ca_id in($wherecaid) ";
$ca_sql .= " order by ca_name ";
$ca_result = sql_query($ca_sql);
for ($ca_i=0; $ca_row = mysql_fetch_array($ca_result); $ca_i++) {
$sql = " select *
from {$cfg[write_table_prefix]}{$bo_table}
where wr_comment = 0 and ca_id = $ca_row[ca_id]
order by wr_id desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$ca_i][$i] = $row;
$list[$ca_i][$i][href] = "./?doc=bbs/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$ca_i][$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$ca_i][$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$ca_i][$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage]);
$list[$ca_i][$i][subject] = conv_subject($row[wr_subject], $title_len,"…");
$list[$ca_i][$i][content] = get_text(cut_str($row[wr_content], $content_len,"…"));
$list[$ca_i][$i][date] = substr($row[wr_datetime],2,8);
$table = "{$cfg[write_table_prefix]}{$bo_table}";
$is_category = false;
if ($bo[bo_use_category]) {
$is_category = true;
$category_option = get_category_option($table);
}
$list[$ca_i][$i][ca_name] = get_category_name($table, $row[ca_id]);
$list[$ca_i][$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$ca_i][$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
}
mysql_free_result($result);
}
mysql_free_result($ca_result);
include "$latest_skin/latest.skin.php";
$latest_skin = $tmp_latest_skin;
}
----- 아래 끝
그리고 루트님의 카테고리별최신글 중에서 카테고리에 해당하는 부분만으로 아래처럼 category2 라는 최신글스킨을 만들었습니다.
----- 아래
<table width=100% bgcolor=#FFFFFF cellpadding=0 cellspacing=0 >
<tr>
<td height=25 style="padding-top:5">
<a href='<?="./?doc=bbs/gnuboard.php&bo_table=$bo_table"?>'><b><font color="#033F87" size="2"><?=$bo_subject?></font></b></a>
</td>
</tr>
<tr>
<td width="100%" height=25 style='line-height:150%;'>
<?
// 카테고리 출력
for ($i=0; $i<count($list); $i++) {
echo "<a href='./?doc=bbs/gnuboard.php&bo_table=$bo_table&sselect=ca_id&stext={$list[$i][0][ca_id]}'>
<font color=#007297>{$list[$i][0][ca_name]}</font></a> ";
}
?>
</td>
</tr>
</table>
----- 아래 끝
이것을
<? latest_cat('category2', 'link1', '10', '10', '30', '1,2,3,4'); ?>
이렇게 호출한 그림이 A 입니다.
그런데 이렇게 만들어진 카테고리추출하는 최신글을 아래와 같이 적용하고자 합니다.
----- 아래
<table>
<?
// 최신글 시작
$gr_id = "Link";
$sql = " select bo_table, bo_subject from $cfg[table_board] where gr_id='$gr_id' and bo_table <> '' and bo_table <> 'link3' order by gr_id, bo_table ";
$result = sql_query($sql);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
// tr 바꾸기
if (($i > 0) && ($i % $list_mod == 0))
echo "</tr><tr>";
echo "
<td width=50% valign=top>
<table width=98% cellpadding=0 cellspacing=0 align=center>
<tr>
<td>";
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법
// latest(스킨, 게시판아이디, 출력라인, 글자수);
// 스킨은 입력하지 않을 경우 운영자 > 환경설정의 최신글 스킨경로를 기본 스킨으로 합니다.
latest("category2", $row[bo_table], 5, 27);
echo "</td></tr></table></td>";
}
if ($i > 0 && ($i % $list_mod == 1))
echo "<td width=50% valign=top> </td>";
?>
</table>
----- 아래 끝
이렇게 해서 만들어진 결과가 그림B입니다.
http://www.sir.co.kr/?doc=bbs/gnuboard.php&bo_table=tiptech&sselect=wr_subject&stext=main&soperator=0&page=1&wr_id=1975 에 적용한 값은 그림 B"입니다.
위그림 B 와 B"에서 카테고리의 이름이 나오는 것이 아니라 카테고리의 번호가 나옵니다.
***** 질문
1 그림 B와 B"에서 카테고리의 이름이 나오게 할 수는 없는가요?
2 그 다음 카테고리의 이름순으로 정렬할 수는 없는가요?
고수님들의 조언을 부탁드립니다.
링크1이 루트님의 글입니다.
http://sir.co.kr/?doc=bbs/gblink.php&bo_table=qa&wr_id=23375&index=1
루트님의 말씀대로 아래부분을 디벨롭.리브에 넣었습니다.
------ 아래 시작
// description : 카테고리별 최신글 추출
// created by : root(http://www.threes.org
// version : 1.0
// created : 2003.12.27
// usage :
// latest_cat('byflower', 'bwork', '10', '20', '50', '1,2,3,4');
// latest_cat('byflower', 'bwork', '10', '10', '50', '');
// sample :
// http://threes.org/gnu3/?doc=main/byflower.php
// http://www.sir.co.kr/?doc=bbs/gnuboard.php&bo_table=tiptech&sselect=&stext=§ion=&page=1&wr_id=2729
function latest_cat($skin_dir='', $bo_table, $rows=10, $title_len=40, $content_len=50, $wherecaid)
{
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] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
// category list
$ca_sql = " select * from {$cfg[write_table_prefix]}{$bo_table}_cat ";
if($wherecaid) $ca_sql .= " where ca_id in($wherecaid) ";
$ca_sql .= " order by ca_name ";
$ca_result = sql_query($ca_sql);
for ($ca_i=0; $ca_row = mysql_fetch_array($ca_result); $ca_i++) {
$sql = " select *
from {$cfg[write_table_prefix]}{$bo_table}
where wr_comment = 0 and ca_id = $ca_row[ca_id]
order by wr_id desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$ca_i][$i] = $row;
$list[$ca_i][$i][href] = "./?doc=bbs/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$ca_i][$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$ca_i][$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$ca_i][$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage]);
$list[$ca_i][$i][subject] = conv_subject($row[wr_subject], $title_len,"…");
$list[$ca_i][$i][content] = get_text(cut_str($row[wr_content], $content_len,"…"));
$list[$ca_i][$i][date] = substr($row[wr_datetime],2,8);
$table = "{$cfg[write_table_prefix]}{$bo_table}";
$is_category = false;
if ($bo[bo_use_category]) {
$is_category = true;
$category_option = get_category_option($table);
}
$list[$ca_i][$i][ca_name] = get_category_name($table, $row[ca_id]);
$list[$ca_i][$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$ca_i][$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
}
mysql_free_result($result);
}
mysql_free_result($ca_result);
include "$latest_skin/latest.skin.php";
$latest_skin = $tmp_latest_skin;
}
----- 아래 끝
그리고 루트님의 카테고리별최신글 중에서 카테고리에 해당하는 부분만으로 아래처럼 category2 라는 최신글스킨을 만들었습니다.
----- 아래
<table width=100% bgcolor=#FFFFFF cellpadding=0 cellspacing=0 >
<tr>
<td height=25 style="padding-top:5">
<a href='<?="./?doc=bbs/gnuboard.php&bo_table=$bo_table"?>'><b><font color="#033F87" size="2"><?=$bo_subject?></font></b></a>
</td>
</tr>
<tr>
<td width="100%" height=25 style='line-height:150%;'>
<?
// 카테고리 출력
for ($i=0; $i<count($list); $i++) {
echo "<a href='./?doc=bbs/gnuboard.php&bo_table=$bo_table&sselect=ca_id&stext={$list[$i][0][ca_id]}'>
<font color=#007297>{$list[$i][0][ca_name]}</font></a> ";
}
?>
</td>
</tr>
</table>
----- 아래 끝
이것을
<? latest_cat('category2', 'link1', '10', '10', '30', '1,2,3,4'); ?>
이렇게 호출한 그림이 A 입니다.
그런데 이렇게 만들어진 카테고리추출하는 최신글을 아래와 같이 적용하고자 합니다.
----- 아래
<table>
<?
// 최신글 시작
$gr_id = "Link";
$sql = " select bo_table, bo_subject from $cfg[table_board] where gr_id='$gr_id' and bo_table <> '' and bo_table <> 'link3' order by gr_id, bo_table ";
$result = sql_query($sql);
for ($i=0; $row=mysql_fetch_array($result); $i++) {
// tr 바꾸기
if (($i > 0) && ($i % $list_mod == 0))
echo "</tr><tr>";
echo "
<td width=50% valign=top>
<table width=98% cellpadding=0 cellspacing=0 align=center>
<tr>
<td>";
// 이 함수가 바로 최신글을 추출하는 역할을 합니다.
// 사용방법
// latest(스킨, 게시판아이디, 출력라인, 글자수);
// 스킨은 입력하지 않을 경우 운영자 > 환경설정의 최신글 스킨경로를 기본 스킨으로 합니다.
latest("category2", $row[bo_table], 5, 27);
echo "</td></tr></table></td>";
}
if ($i > 0 && ($i % $list_mod == 1))
echo "<td width=50% valign=top> </td>";
?>
</table>
----- 아래 끝
이렇게 해서 만들어진 결과가 그림B입니다.
http://www.sir.co.kr/?doc=bbs/gnuboard.php&bo_table=tiptech&sselect=wr_subject&stext=main&soperator=0&page=1&wr_id=1975 에 적용한 값은 그림 B"입니다.
위그림 B 와 B"에서 카테고리의 이름이 나오는 것이 아니라 카테고리의 번호가 나옵니다.
***** 질문
1 그림 B와 B"에서 카테고리의 이름이 나오게 할 수는 없는가요?
2 그 다음 카테고리의 이름순으로 정렬할 수는 없는가요?
댓글 전체
죄송하지만 손좀 봐주세요....
제가보기에는 이것이 가능해지면 고수님들 실력으론 카페나 클럽플러그인을 만드는 것보다 더 쉽게 링크사이트만드는 플러그인도 가능한 것 같은데...
제가보기에는 이것이 가능해지면 고수님들 실력으론 카페나 클럽플러그인을 만드는 것보다 더 쉽게 링크사이트만드는 플러그인도 가능한 것 같은데...
소스 곳곳에서 오타스러운 문장들이 보이는데.. 제가 root 님의 최신글을 사용하지 않는 터라 잘 모르겠군요.. 어쨌든 그리 어려워 보이는 일은 아닙니다..
그렇지 않으면 구조상 아예 불가능한 일인가요?
혹시 엄청난 노가다가 필요한 일인가요?
고수님들께서 손끝만 움직여주시면 간단하게 끝날 것 같은데....