최신글 스킨에서 댓글 달리면 제목이 출력 안되는 문제 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

최신글 스킨에서 댓글 달리면 제목이 출력 안되는 문제 정보

최신글 스킨에서 댓글 달리면 제목이 출력 안되는 문제

본문

오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.

오류 주소 : www.memorystory.net


안녕하세요. 항상 고마움 느끼며 잘 배우고 있습니다.

이번에 허접한 실력으로 사이트를 만들었습니다;;

그런데, 사이트 메인 화면에 최신글 스킨을 삽입하고 보니

댓글이 달리면 제목이 생략되고 댓글 갯수만 나오네요.

그리고 한 개의 글에 댓글이 1개 2개 3개 달릴 때마다

1. (1)
2. (2)
3. (3)

이런 식으로 중복되어서 나옵니다.

최신글 스킨은

http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=87769&sca=%EC%B5%9C%EC%8B%A0%EA%B8%80&page=25

여기서 받았구요.

혹시나, 중복 문제일까 싶어 1개만 해봤는데도 똑같이 그러네요.

몇 시간 동안 해보다가 도저히 해결되지 않아 이렇게 글로 남깁니다.

아시는 분들 가르쳐 주시면 정말 감사하겠습니다. (_ _)
  • 복사

댓글 전체

네 화끈하게 님 참고로 배추빌더 사용하고 있구요.

우선 메인 소스 중 오류 나는 최신글 부분은요,

<table width="725" border="0" cellpadding="0" cellspacing="0"
bordercolor="#e1e1e1" bgcolor="white">
  <tr>
  <td><div style="margin:5px 0 0 0;">
  <?include_once("./_common.php"); ?>
  <?include_once("$g4[path]/lib/kb.today.lib.php"); ?>
  <? echo latest_today("today","","",5,60,"wr_good","","2012-10-01 2012-10-31");?>
 
  </div>
  </td>
  <td><div style="margin:5px 0 0 5;">
  <? echo latest_today("today2","","",5,60,"wr_comment","","2012-10-01 2012-10-31");?> 
  </div>
  </td>
  </tr></table>

윗부분이고, 관련 파일 kb.today.lib.php 는요

<?php
/*
 * filename : kb.today.lib.php
 * version : 2.9
 * date : 2010년 2월 16일 화요일 오후 20:30:28
 */

// 검색 쿼리 생성
function get_sql_search_union($member_board, $sql_search, $sst="wr_comment")
{
global $g4;

$sql_common =<<< EOD
, ca_name, wr_num, wr_reply, wr_datetime, wr_subject, wr_name, wr_comment, wr_is_comment, wr_content, wr_ip, wr_last
, wr_email, wr_homepage, wr_option, wr_link1, wr_link2, wr_link1_hit, wr_link2_hit, wr_hit, wr_good, wr_nogood
, wr_1, wr_2, wr_3, wr_4, wr_5, wr_6, wr_7, wr_8, wr_9, wr_10
EOD;

$sql = $sql_cnt = "";
// 댓글, 조회, 추천, 비추천, 링크1조회, 링크2조회 순일 때
if ($sst != "bf_download" && $sst != "scrap") {
$bo_count = count($member_board);
$i=0;
$sst = "";
foreach ($member_board as $board)
{

$write_table = $g4[write_prefix] . $board[bo_table];

$sql .= $op;
$sql_cnt .= $op;

$sql .= <<<EOD
select '$board[bo_table]                                                    '  as bo_table, '$board[bo_subject]                                          ' as bo_subject, '$board[gr_subject]                                ' as gr_subject,
wr_id, mb_id $sst $sql_common
  from $write_table where 1 $sql_search
EOD;

$sql_cnt .=<<<EOD
select cast('$board[bo_table]                                            ' as  bo_table, count(*) as cnt from $write_table where 1 $sql_search
EOD;

$op = " union ";
}
}
else { // 다운로드순 또는 스크랩순일때
if ($sst == "bf_download") {
$joinTable = $g4[board_file_table];
$count_sst = " , sum(bf_download) as $sst ";
}
else {
$joinTable = $g4[scrap_table];
$count_sst = " , count(ms_id) as $sst ";
// $g4[scrap_table]과 $g4[write_table]의 mb_id 중복으로 where 절에서 발생하는 오류 방지
$sql_search = preg_replace("/[[:space:]]+mb_id[[:space:]]+/", "a.mb_id", $sql_search);
}

$result = sql_query(" select distinct bo_table from $joinTable ");
$joinTable_board = array();
while ($row = sql_fetch_array($result))
$joinTable_board[] = $row[bo_table];

foreach ($member_board as $key => $board) {
if (!in_array($board[bo_table], $joinTable_board))
unset($member_board[$key]);
}

$bo_count = count($member_board);
foreach ($member_board as $board)
{
$write_table = $g4[write_prefix] . $board[bo_table];

$sql .= $op;
$sql_cnt .= $op;

$sql .=<<<EOD
select '$board[bo_table]                                              ' as bo_table, '$board[bo_subject]                                    ' as bo_subject, '$board[gr_subject]                                  ' as gr_subject,
b.wr_id, a.mb_id $sql_common $count_sst
from $write_table a, $joinTable b
where 1 and b.bo_table='$board[bo_table]' and a.wr_id=b.wr_id $sql_search
group by b.bo_table, b.wr_id
EOD;

$sql_cnt .=<<<EOD
select '$board[bo_table]                                              ' as  bo_table, b.wr_id, count(distinct b.wr_id) as cnt
from $write_table a, $joinTable b
where 1 and b.bo_table='$board[bo_table]' and a.wr_id=b.wr_id $sql_search
group by b.bo_table, b.wr_id
EOD;

$op = " union ";
}
}
return array($sql, $sql_cnt);
}

// 전체게시판 또는 특정 게시판의 파일첨부 게시물 총개수
function get_file_cnt($bo_table="")
{
global $g4;

if ($bo_table)
$sql_search = " group by wr_id having bo_table='$bo_table' ";
else
$sql_search = " group by bo_table, wr_id ";
$sql = "select bo_table from $g4[board_file_table] $sql_search ";
$result = sql_query($sql);
return mysql_num_rows($result);
}

//2010-01-01 형식의 날짜가 존재하면 참
function get_sql_search_date ($strDate)
{
$strDate = trim($strDate);
$wr_datetime = explode(" ", $strDate);
if (2>count($wr_datetime)) {
// 검색날짜가 1개이면
$sql_search = " wr_datetime <= '$wr_datetime[0] 23:59:59' "; //  과거부터 지정일까지만
}
else {  // 검색날짜가 2개이면
$sql_search = " wr_datetime between '$wr_datetime[0] 00:00:00' and '$wr_datetime[1] 23:59:59' "; //지정기간에만
}

return $sql_search;
}

//2010-01-01 형식의 날짜가 존재하면 참
function checkdate_kr ($ymd, $delimiter="-")
{
$valid = false;
$date = explode(" ", trim($ymd));
for ($i=0; $i<2; $i++) {
if ($date[$i] && strstr($date[$i], $delimiter)) {
$sdate = explode($delimiter, $date[$i]);
if(checkdate($sdate[1], $sdate[2], $sdate[0]))
$valid = true;
else
return false;
}
}
return $valid;
}

// 최신글 추출
// latest_today("최신글스킨폴더명", "그룹명", "게시판명", "목록개수", "제목길이", "정렬필드명, "정렬방법", "기간")
function latest_today($skin_dir="", $gr_id="", $bo_table="", $rows=10, $subject_len=60, $sst="wr_comment", $sod="desc", $sdate="")
{
    global $g4, $member;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

$member_board = array();
// 그룹아이디와 게시판명이 없으면 전체 게시판을 가져온다.
if (empty($gr_id) && empty($bo_table)) {
$member_board = get_member_board($member[mb_id]);
}
else {
$gr_id = explode(",", $gr_id);
foreach ($gr_id as $grid) {
if (empty($grid)) continue;
$member_board = array_merge($member_board, get_member_board($member[mb_id], trim($grid), ""));
}

$bo_table = explode(",", $bo_table);
foreach ($bo_table as $table) {
if (empty($table)) continue;
$member_board = array_merge($member_board, get_member_board($member[mb_id], "", trim($table)));
}
}

if (!$sst) $sst = "wr_comment";
if (!$sod) $sod = "desc";

$sql_search = " and wr_is_comment='0' ";
if ($sdate && checkdate_kr($sdate)) {
$sql_search =  get_sql_search_date($sdate);
if ($sql_search) $sql_search = " and " . $sql_search;
}

list($sql_select, $sql_count) = get_sql_search_union($member_board, $sql_search, $sst);

if ( !empty($sql_select))
{
$sql_order = " order by $sst $sod, wr_num, wr_reply limit 0, $rows";
$sql = $sql_select . $sql_order;

$content = "";
$list = array();
$result = sql_query($sql);
$i=0;

while($row = sql_fetch_array($result)){
$board[bo_table] = trim($row[bo_table]);
$bo_table = $row[bo_table];
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$i++;
}
}

ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();


return $content;
}

function get_member_board($mb_id="", $gr_id="", $bo_table="")
{
global $g4;
$sql = "
select a.bo_table, a.gr_id, b.gr_subject, a.bo_subject, a.bo_list_level, b.gr_use_access from
$g4[board_table] a, $g4[group_table] b
where a.gr_id=b.gr_id ";

// 그룹이 있으면 해당 그룹 검색
if ($gr_id)  $sql_search = " and a.gr_id='$gr_id' ";
else if ($bo_table) $sql_search = " and a.bo_table='$bo_table' "; // 게시판이 있으면 그룹은 제거하고 게시판만 검색

// 최고관리자가 아니면 검색허용 게시판만, 접근허용 게시판만
if (is_admin($mb_id) != "super") {
$result = sql_query("select gr_id from $g4[group_member_table] where mb_id='$mb_id' ");
$group_member_board = array();
while($row = sql_fetch_array($result))
$group_member_board[] = "'" . $row[gr_id] . "'";

if ($group_member_board)
$sql_gr_use_access = " or b.gr_id in ( " . implode("," , $group_member_board) . ")";

$sql_search .=<<<EOD
and a.bo_use_search='1' and
(
b.gr_use_access='0' $sql_gr_use_access
)
EOD;
}

$sql .= $sql_search;
$result = sql_query($sql);

$board_list = array();
for($i=0; $board = sql_fetch_array($result); $i++)
$board_list[] = $board; // 그룹접근 미사용인 경우

return $board_list;
}

function get_rows_select($name, $value='', $selected='', $event='')
{
$arr_cnt=$value;
if (empty($arr_cnt) || !is_array($arr_cnt)) $arr_cnt = array(10, 15, 20, 30, 40, 50, 100, 200);

$selectbox = "<select name='$name' id='$name' $event>\n";
foreach ($arr_cnt as $cnt) {
$selectbox .= "<option value='$cnt'";
if ($cnt==$selected) $selectbox .= " selected";
$selectbox .= ">{$cnt}개씩 보기</option>\n";
}
$selectbox .= "</select>\n";

return $selectbox;
}
?>








이렇게 되고, 최신글 스킨은요,









<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>

<style type="text/css">
span.comment { font-family:Tahoma; font-size:10px; color:#EE5A00; }
a.latest_title  { color:#FF4D4D; font-family:gulim; font-weight:bold; font-size:15px; width:100%; display:block;}
a.latest_more  { color:dimgray; font-family:Tahoma; font-size:13px; width:100%; display:block;}
a.latest_title:hover, a.latest_more:hover { color:blue;}
</style>



<table width="360" border="1" cellpadding="5" cellspacing="0"
bordercolor="#e1e1e1" bgcolor="white" style="BORDER-COLLAPSE: collapse">
<tr><td>
<table width=100% cellpadding=0 cellspacing=0 style="margin-bottom:10px;">
<tr>
<td colspan="4" style='padding-bottom:10px'>
<div style="width:99%; padding-left:5px; padding-right:5px; border-bottom:1px solid gray;">
<table width="100%"><tr>
<td width='16'><img src="<?=$latest_skin_path;?>/img/medal.gif"></td>
<td> <a href="<?=$g4[path]?>/today.php" class="latest_title" title="추천 BEST 5">
추천 BEST 5</a></td>
<td width='40' align='right'><a href="<?=$g4[path]?>/today.php" class='latest_more' title="추천 BEST 5">more</a></td>
</tr></table>
</div>
</td>
</tr>
<? for ($i=0; $i<count($list); $i++) { ?>
<tr>
    <td colspan=4 style="padding-left:5px;" height="20">

            <?
echo sprintf("<font color=#88844E size='2'> %02d. </font>", ($i+1)  );
            echo "<a href='{$list[$i]['href']}'>";
            echo "<font color='#88844E' size='2' face='돋움체'> {$list[$i]['subject']} </font>";
            echo "</a>";

            if ($list[$i]['comment_cnt'])
                echo " <a href=\"{$list[$i]['comment_href']}\"><span class='comment'>{$list[$i]['comment_cnt']}</span></a>";

            // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
/*
      echo " " . $list[$i]['icon_new'];
            echo " " . $list[$i]['icon_file'];
            echo " " . $list[$i]['icon_link'];
            echo " " . $list[$i]['icon_hot'];
            echo " " . $list[$i]['icon_secret'];
*/
            ?>

</td>
</tr>
<? } ?>

<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td></tr><? } ?>

</table></td></tr></table>


이렇게 입니다...
© SIRSOFT
현재 페이지 제일 처음으로