카테고리중 원하는 것만 최신글로 뽑는 방법이요... > 그누3질답

그누3질답

카테고리중 원하는 것만 최신글로 뽑는 방법이요... 정보

그누보드 카테고리중 원하는 것만 최신글로 뽑는 방법이요...

본문

다음의 이부분은 lib/latest.lib.php 에 추가
// 카테고리 추출
function latest_category($skin_dir='', $bo_table, $rows=10, $len=40)
{
  global $latest_skin, $cfg;

  $tmp_latest_skin = $latest_skin;

  // 스킨디렉토리값이 넘어왔다면
  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];

$table = "{$cfg[write_table_prefix]}{$bo_table}";

$sql = " select a.*, mb_open
            from $table a
            left join $cfg[table_member] b on (b.mb_id = a.mb_id)
            where a.wr_comment = 0
            order by a.wr_num, a.wr_datetime 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]/_board_.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);
      $wr_id = $row[wr_id];

if ($bo[bo_use_category]) {  //카테고리가 있다면
$show_category_begin = "";
$show_category_end = "";
} else {      //카테고리가 없다면
$show_category_begin = "<!--";
$show_category_end  = "-->";
}

$list[$i][ca_name] = $wr_id = "";          // 분류를 뽑을 때 사용
        if ($row[wr_id]) {
      $sql1 = " select ca_name from {$table}_cat where ca_id = '$row[ca_id]'";
      $row1 = sql_fetch($sql1);
        if ($row1[ca_name])
      $list[$i][ca_name] = "[$row1[ca_name]]";
        }

$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> ";
      }

$list[$i][reply] = "";
if (strlen($row[wr_reply]) > 0) {
for ($k=0; $k<strlen($row[wr_reply]); $k++) {
$list[$i][reply] .= "    ";
}
}

$list[$i][icon_reply] = "";
if ($list[$i][reply]) {
  $list[$i][icon_reply] = "<img src='$latest_skin/icon_reply.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);
   
  include "$latest_skin/latest.skin.php";

  $latest_skin = $tmp_latest_skin;
}

/////////////////////////

그리고
skin/latest/category 폴더에 latest.skin.php를

        <table width=100% bgcolor=#FFFFFF cellpadding=0 cellspacing=0 border=0>
        <tr><td colspan=2 height=10></td></tr>

        <? for ($i=0; $i<count($list); $i++) { ?>
<? if ($i==0){?>


<tr><td colspan=2 height=1 background='$latest_skin/dot_line.gif' width=7 height=7></td></tr>
        <tr>
            <td width=30 align=center><img src='<?=$latest_skin?>/icon_li.gif' width=7 height=7></td>
            <td width='' height=20>
<?=$show_category_begin?><?=$list[$i][ca_name]?><?=$show_category_end?><?=$list[$i][reply]?><?=$list[$i][icon_reply]?><?=$list[$i][icon_new]?><a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><span class=content><?=$list[$i][subject]?></a><span style='font-size:8pt;'><?=$list[$i][commentcnt]?></span></span></a> <?=$list[$i][icon_new]?>
</td>
        </tr>
<tr height=44>
<td width=30 align=center></td>
<td colspan=2 width='' height=44>
<table width=100% cellpadding=0 cellspacing=0>
<tr height=44>
<td><?=nl2br(stripslashes($list[$i][content]))?></td>
</tr>
</table>
</td>
</tr>

<? }else{?>

<table width=100% cellpadding=0 cellspacing=0>
<tr height=22>
<td><?=$list[$i][icon_new]?><?=$show_category_begin?><?=$list[$i][ca_name]?><?=$show_category_end?><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]?></td>
</tr>
<? } ?>
<? } ?>

        <? if (count($list) == 0) { echo "<tr><td colspan=2 align=center height=50>자료가 없습니다.</td></tr>"; } ?>

        <tr><td colspan=2 height=5></td></tr>
        </table>

만들어 넣었습니다.

여기서 카테고리 중 ca_id 의 1,2,3 중 1이나 2 또는 3중 원하는 것 하나만 추출 하려면 어떻해야 하나요

댓글 전체

<?
if (defined(__FILE__)) return;
define(__FILE__, TRUE);

//==============================================================================
//  최신글 관련 함수
//==============================================================================


// 최신글 추출
function grlatest($skin_dir='', $bo_table, $rows=10, $len=40, $ca_id )
{
    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];

if($ca_id > 0) {
    $sql = " select *
              from {$cfg[write_table_prefix]}{$bo_table}
              where wr_comment = 0
  and ca_id=$ca_id
              order by wr_id desc limit 0, $rows ";
 } else {
      $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/board.php&bo_table=$bo_table&wr_id=$row[wr_id]&sselect=ca_id&stext=$ca_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;
}
?>

위 내용을 developer.lib.php 에 넣어 주시던지. 임이의 파일을 만들어
예) grlatest.lib.php 파일에 위 내용을 넣어서 저장해서 lib 폴더에 넣습니다..

그럼후 최신글 스킨에 <?=grlatest('최근스킨',게시판명, 글수, 제목제한,카테고리id값); ?>
<?=grlatest('basic',board, 4,60,1); ?>
이런 식으로 넣으시면 됩니다. (__)
전체 9,564
그누3질답 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT