gblist.php 의 아래부분에서
// 정렬
if (!$ssort) {
$ssort = "wr_notice, wr_num, wr_reply";
$sorder = "";
}
아래에
아래와 같이 추가하여 사용합니다
if($bo_table==home_stay){//게시판이 홈스테이일경우
$ssort = "wr_datetime";//정렬은 날짜순으로
$sorder = "asc";//입력한순서부텀 desc로하면 최근 날짜순으로...
}
위와 같이 응용하여 씁니다
// 정렬
if (!$ssort) {
$ssort = "wr_notice, wr_num, wr_reply";
$sorder = "";
}
아래에
아래와 같이 추가하여 사용합니다
if($bo_table==home_stay){//게시판이 홈스테이일경우
$ssort = "wr_datetime";//정렬은 날짜순으로
$sorder = "asc";//입력한순서부텀 desc로하면 최근 날짜순으로...
}
위와 같이 응용하여 씁니다
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 19개
이글 원래의 질문에서 정렬을 다르게 하고자하는 게시판에 여러개일경우는 어떻게 해야되는가요?
번번히 신세를 지는군요, 감사합니니다.
언젠가는 필리핀에 가봐야 하는데.....
감사합니다.
립에서 레이티스트 함수를 복사해서
function latest2($skin_dir='', $bo_table, $rows=10, $len=40)
{
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];
$sql = " select *
from {$cfg[write_table_prefix]}{$bo_table}
where wr_comment = 0
order by wr_id asc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;
$list[$i][href] = "./?doc=bbs/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]);
$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;
}
이렇게 투로 만든다음
보여줄곳에 latest2('',게시판명,글수.제목글자수) 해보셔요...
특정게시판의 최신글에서만 적용하고 싶어요.
$sql = " select *
from {$cfg[write_table_prefix]}{$bo_table}
where wr_comment = 0
order by wr_id desc limit 0, $rows ";
order by wr_id asc limit 0, $rows ";
이렇게해보셔요...그렇지만...다른 최신글들도 함께그렇게 될거여요...
(이곳 만도님의 가르침대로..)
최신글의 정렬도 asc로 정렬되게 하고자 합니다.
위 링크의 메뉴부분이 최신글입니다.
그것을 리스크와 같게하고자 합니다.
---------------------------------
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<table width=170 cellpadding=0 cellspacing=0 align=center border=1 bordercolordark="#ECECDC" bordercolorlight="#000000">
<tr>
<td width="100%" align="left">
<table width=100% align="left">
<tr>
<td height=22 valign="middle">
<img src='<?=$latest_skin?>/female_n.gif' >
<a href='./?doc=bbs/gnuboard.php&bo_table=<?=$bo_table?>'><b><?=$bo_subject?></b></a>
</td>
</tr>
<tr>
<td align="left">
<table width=100% cellpadding=0 cellspacing=0 border=0 align="left">
<? for ($i=0; $i<count($list); $i++) { ?>
<? /* if ($i) { echo "<tr><td colspan=2 height=1 background='$latest_skin/dot_line.gif' width=7 height=7></td></tr>"; } */?>
<tr>
<td width=15 align=center><img src='<?=$latest_skin?>/icon_li.gif'></td>
<td width='' height=22> <a href='<?="./?doc=bbs/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><span style='font-size:9pt;'><?=$list[$i][subject]?> </span> <span style='font-size:8pt;'><?=$list[$i][commentcnt]?></span></a> <?=$list[$i][icon_new]?></td>
</tr>
<? } ?>
<? if (count($list) == 0) { echo "<tr><td colspan=2 align=center height=50>자료가 없습니다.</td></tr>"; } ?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
아래는 latest.lib 입니다.
------------------------
<?
if (defined(__FILE__)) return;
define(__FILE__, TRUE);
//==============================================================================
// 최신글 관련 함수
//==============================================================================
// 최신글 추출
function latest($skin_dir='', $bo_table, $rows=10, $len=40)
{
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];
$sql = " select *
from {$cfg[write_table_prefix]}{$bo_table}
where wr_comment = 0
order by 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=bbs/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]);
$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;
}
?>