한가지만 더...
그룹최신글에 관련해서요,.. 질답란하고 팁란에 다 찾아봐도,
다 적용해봐도 최신글에서 이미지는 계속 노출되지 않습니다...
을 참고 했지만 부분적인 문제만 해결되고 계속 문제점이 존재하네요.
예를들어 A라는 그룹에 1~10까지의 게시판이 있다면 항상
마지막 게시판의 이미지만 제대로 출력됩니다.
4개면 4번째 게시판의 이미지만, 8개라면 8번째 게시판 이미지만
출력됩니다. 다른 이미지는 다 제대로 노출되지 않습니다.
어느 고수분 이문제좀 가르쳐 주세요,.
제가 실행해 보고 확실히 된다면 모두 정리해서 다른 초보자 분들과 함께 공유할겁니다.
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 11개
if (!defined('_GNUBOARD_')) exit;
/// 함수 정의 시작
// 최신글 추출 - 선택한 그룹별로 원하는 수만큼 보여줌
function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $category="", $orderby="")
{
global $config;
global $g4;
$list = array();
$limitrows = $rows;
$sqlgroup = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' and bo_use_search=1 order by bo_order_search";
$rsgroup = sql_query($sqlgroup);
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]";
for ($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) {
$bo_table = $rowgroup[bo_table];
// 테이블 이름구함
$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 실제이름
// 옵션에 따라 정렬
$sql = "select * from $tmp_write_table where wr_is_comment = 0 ";
$sql .= (!$category) ? "" : " and ca_name = '$category' ";
$sql .= (!$orderby) ? " order by wr_id desc " : " order by $orderby desc, wr_id desc ";
$sql .= " limit $limitrows";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++, $k++) {
if(!$orderby) $op_list[$k] = $row[wr_datetime];
else {
$op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]);
$op_list[$k] .= $row[wr_datetime];
}
$list[$k] = get_list($row, $board, $latest_skin_path, $subject_len);
$list[$k][bo_table] = $board[bo_table];
$list[$k][bo_subject] = $board[bo_subject];
$list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len);
}
}
if($k>0) array_multisort($op_list, SORT_DESC, $list);
if($k>$rows) array_splice($list, $rows);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/// 함수 정의 끝
?>
어떤 latest.skin.php 를 쓰시는지는 모르지만...
위의 함수는 그룹에서 게시판을 쿼리하는 기능입니다.
bbs/group.php 의 방법도 있을겁니다.
게시판관리-그룹관리에서 해당 그룹을 찍어주면 같은 효과가 됩니다.
.
.
함수에서 for 문의 끝이 명확하지 않는데 어떻게 다들...??? 아이러니..네요.
.
.
.
.
일단 표시는 이렇게 해보세요. 이미지의 출력은 고사하고 그룹에 속한 게시판은 모조리 출력이 되어야 겠지요.
/* 촐력 */
<table width="100%" cellpadding=0 cellspacing=0>
<tr>
<td width="100%" style="word-break:break-all; padding-left:0px;" wrap>
<!-- ----------------------------------------->
<?echo latest_group("basic","gb4_baedal", 5, 70);?>
</td>
</tr>
</table>
/* 함수 */
<?
if (!defined('_GNUBOARD_')) exit;
/// 함수 정의 시작
// 최신글 추출 - 선택한 그룹별로 원하는 수만큼 보여줌
function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $category="", $orderby="")
{
global $config;
global $g4;
$limitrows = $rows;
$sqlgroup = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' and bo_use_search=1 order by bo_order_search";
$rsgroup = sql_query($sqlgroup);
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]";
for($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) {
$bo_table = $rowgroup[bo_table];
// 테이블 이름구함
$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 실제이름
// 옵션에 따라 정렬
$sql = "select * from $tmp_write_table where wr_is_comment = 0 ";
$sql .= (!$category) ? "" : " and ca_name = '$category' ";
$sql .= (!$orderby) ? " order by wr_id desc " : " order by $orderby desc, wr_id desc ";
$sql .= " limit $limitrows";
$result = sql_query($sql);
$list = array();
reset($list);
for ($i=0; $row = sql_fetch_array($result); $i++, $k++) {
if(!$orderby) $op_list[$k] = $row[wr_datetime];
else {
$op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]);
$op_list[$k] .= $row[wr_datetime];
}
$list[$k] = get_list($row, $board, $latest_skin_path, $subject_len);
$list[$k][bo_table] = $board[bo_table];
$list[$k][bo_subject] = $board[bo_subject];
$list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len);
}
if($k>0) @array_multisort($op_list, SORT_DESC, $list);
if($k>$rows) array_splice($list, $rows);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = @ob_get_contents();
}
ob_end_clean();
return $content;
}
/// 함수 정의 끝
?>
$list에 bo_table 값이 제각각 들어 가야 하는데
file 처리하는 부분에서 일괄적으로 마지막 게시판의 bo_table만 이용하기 때문에
앞서 있던 게시판의 file 경로가 맞지 않기 때문일 겁니다.
$image_height = 85; // 높이
$image_width = 125; // 너비
?>
<table width=100% cellpadding=0 cellspacing=1 border=0>
<? for ($i=0; $i<count($list); $i++) { ?>
<? if ($i==0){?>
<tr>
<td height=22 colspan="3" valign=middle><table width=100% cellpadding=0 cellspacing=0 align=center border=0>
<tr>
<td height=22><?
echo $list[$i][icon_reply] . " ";
echo "<a href='{$list[$i][href]}'>";
if ($list[$i][is_notice])
echo "<font style='font-family:µ¸¿ò; font-size:18pt; color:#000000;'><strong>{$list[$i][subject]}</strong></font>";
else
echo "<font style='font-family:µ¸¿ò; font-size:18pt; color:#000000;'><strong>{$list[$i][subject]}</strong></font>";
echo "</a>";
//if ($list[$i][comment_cnt]) echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:µ¸¿ò; font-size:8pt; color:#9A9A9A;'>{$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>
<td align=right> <a href="<?=$list[$i][ca_name_href]?>">
<?=$list[$i][ca_name]?>
</a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="18" valign=middle><?
echo "<a href='{$list[$i][href]}'>";
$image = urlencode($list[$i][file][0][file]); // 첫번째 파일이 이미지라면
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
echo "<img src='$g4[path]/data/file/$bo_table/$image' width='$image_width' height='$image_height' border=3 style='border-color:EFEFEF;' align=left>"; // 이미지크기
} else
if (file_exists($list[$i][file_image1])) { $gznews_img = "width='$image_width' height='$image_height' border=3 style='border-color:EFEFEF;' align=left>"; }
?></td>
<td width="5" valign=middle> </td>
<td width='*' valign=middle>
<p align=justify><a href='<?=$list[$i][href]?>'><font style='font-family:돋움; font-size:10pt; color:#6A6A6A;'><?=cut_str(strip_tags($list[$i][wr_content]),300,"...")?></font></a>
</td>
</tr>
<!-- 경계선 -->
<tr bgcolor=#FFFFFF height=5><td colspan=3></td></tr>
<? }else{?>
<tr>
<td height="20" colspan=3>
<img src='<?=$latest_skin_path?>/img/icon_li.gif' width="18" height="14"> <?
echo $list[$i][icon_reply] . " ";
echo "<a href='{$list[$i][href]}'>";
if ($list[$i][is_notice])
echo "<font style='font-family:돋움; font-size:11pt; color:##000033;'><strong>{$list[$i][subject]}</strong></font>";
else
echo "<font style='font-family:돋움; font-size:11pt; color:##000033;'><strong>{$list[$i][subject]}<strong></font>";
echo "</a>";
//if ($list[$i][comment_cnt])echo " <a href=\"{$list[$i][comment_href]}\"><span style='font-family:돋움; font-size:8pt; color:#9A9A9A;'>{$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) { echo "<tr><td colspan=3 align=center height=50>자료가 없습니다.</td></tr>"; } ?>
</table>
이게 스킨파일입니다.
마지막 게시판에서만 이미지가 출력된다고 하셨죠?
제가 말씀드린 부분을 적용을 안하셨네요.
변칙적으루 스킨파일을 인클루드하기 전에 소트된 후 list배열에서 테이블값이 포함된 다른 자료값을 받아와서 잘라 사용하면 되거든요..;;
스킨파일에 삽입해두 됩니다만.. 어짜피 변수 bo_table은 스킨에선 사용하질 않으니깐 lib에 포함시키는게 효율적이겠네요..;;
lib함수 맨하단부분에 정렬된 후, explode로 $list[0][href] 값을 잘라 사용하면 됩니다.
아래와 같이요..;; 난이도 높은건 저에게 어렵기때문에.. 되도록 쉽게 살아가야죠..;;
------------------------------------------------------------------------------------------------------------------
}
//for루프구문 끝
if($k>0) array_multisort($op_list, SORT_DESC, $list); //정렬(array_multisort는 멀티배열정렬)
if($k>$rows) array_splice($list, $rows); //쓸모없는 배열 부분 삭제(array_splice는 배열일부삭제 다른내용대체함수)
//첫번째 자료값에서 최신글링크를 추출해서 테이블값만 잘라 사용함 -0-
$bo_1 = explode("bo_table=",$list[0][href]); //먼저 bo_table=를 자르고
$bo_2 = explode("&",$bo_1[1]); //&로 자르면 테이블값만 남음 --;;
$bo_table = trim($bo_2[0]); //뽀대용 trim -0-
//여기까지
ob_start();
include "$latest_skin_path/latest.skin.php"; //내용을 인클루드
$content = ob_get_contents();
ob_end_clean();
return $content;
//함수부분끝
}