다중카테고리를 이용할때 서브카테고리 배열 표시하기... 정보
다중카테고리를 이용할때 서브카테고리 배열 표시하기...본문
기본카테고리 "test"에 서브카테고리 "a", "b"
기본카테고리 "test2"에 서브카테고리 "c"
기본카테고리 "test3"에 서브카테고리 "d", "e"
라고 가정할때
|a^b|c|d^e|
와 같은 형태로 미리 분류에 놓은 bo_10을 이용 쓰기에서 wr_10으로 서브카테고리를 입력받은 나라오름님의 스킨
을 이용하여
스킨의 list에 인클루드하여 카테고리를 나열하여 보여주는 아래의 페이지에...
category.php
--------------------------------------------------------------
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<? $cnt_bo_1 = 5; // 한줄당 분류 갯수 ?>
<!-- 분류 셀렉트 박스 시작 -->
<?
$cnt = 1;
$sql = " SELECT bo_category_list FROM $g4[board_table] WHERE bo_table = '$bo_table' ";
$row = sql_fetch($sql);
$arr = explode("|", $row[bo_category_list]); // 구분자가 , 로 되어 있음
$str = "";
$str .= "<tr>";
for ($i=0; $i<count($arr); $i++)
if (trim($arr[$i])) {
$sql1 = " SELECT count(*) as cCount FROM $write_table WHERE ca_name='$arr[$i]' and wr_is_comment='0'";
$row1 = sql_fetch($sql1);
$str .= "<td><a class='cate' href='./board.php?bo_table=$bo_table&page=$page&mode=$mode&sca=$arr[$i]'><font color='#76a581'>$arr[$i]<b> ($row1[cCount])</b></font></a></td>";
if ($cnt == $cnt_bo_1) { $cnt = 0; $str .= "</tr><tr>"; }
$cnt++;
}
$sql2 = " SELECT count(*) as cCount FROM $write_table WHERE wr_is_comment = '0' ";
$row2 = sql_fetch($sql2);
$Total_Cat = $row2[cCount]
?>
$sql2 = " SELECT count(*) as cCount FROM $write_table WHERE wr_is_comment = '0' ";
$row2 = sql_fetch($sql2);
$Total_Cat = $row2[cCount]
?>
<table width=100% cellspacing=1 cellpadding=4 border=0 style=table-layout:fixed>
<col width=90></col>
<col width=20></col>
<col width=></col>
<col width=90></col>
<col width=20></col>
<col width=></col>
<tr bgcolor=white>
<td align='center'>
<img src='<?=$board_skin_path?>/img/ico_folder.gif' width='16' height='11'> <a class='cate' href='./board.php?bo_table=<?=$bo_table?>&sca=<?=$arr[$i]?>&sop=&sst=wr_id&sod=desc&sfl=&stx=&page=1'><font color='#76a581'><b>전체 (<?=$board[bo_count_write]?>)</b></font></a>
</td>
<td nowrap> </td>
<td width='' style='word-break:break-all;'>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<span class="cate"><?=$str?></span>
</table>
</td>
</tr>
</table>
<!-- 분류 셀렉트 박스 끝 -->
<td align='center'>
<img src='<?=$board_skin_path?>/img/ico_folder.gif' width='16' height='11'> <a class='cate' href='./board.php?bo_table=<?=$bo_table?>&sca=<?=$arr[$i]?>&sop=&sst=wr_id&sod=desc&sfl=&stx=&page=1'><font color='#76a581'><b>전체 (<?=$board[bo_count_write]?>)</b></font></a>
</td>
<td nowrap> </td>
<td width='' style='word-break:break-all;'>
<table border=0 cellspacing=0 cellpadding=0 width=100%>
<span class="cate"><?=$str?></span>
</table>
</td>
</tr>
</table>
<!-- 분류 셀렉트 박스 끝 -->
----------------------------------------------------------------------
서브카테고리와 그 서브카테고리의 게시물수를 기본카테고리 옆에 표시하고자 합니다.
단순히
$arr2 = explode("|", $row[bo_10]); // 구분자가 , 로 되어 있음
과 같은 정의를 추가하여 표시하려 해보았으나,
bo_10에 정의된 ^로 구분한 기본카테고리의 개별서브카테고리를 분리를 못하겠더군요.
가장 근접한 답을 주시는 분의 답변을 기다리겠습니다.
댓글 전체
ㅎㅎㅎ