고수님들... 랜덤함수 배열에 관한 간단한 문제... 정보
고수님들... 랜덤함수 배열에 관한 간단한 문제...
본문
extend 폴더에 developer.lib.php 라는 다음 코드의 파일을 넣고요 :
<?
if (!defined('_GNUBOARD_')) exit;
// 랜덤게시물 추출
// extend 디렉토리에 developer.lib.php파일을 올린다
// random_latest("최신글스킨명", 테이블명, 불러올갯수, 제목길이);
function random_latest($skin_dir="", $bo_table, $rows=10, $subject_len=40)
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$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 order by rand() desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
-------------------------------------------------------------------------------------------------------------
갤러리를 불러오는 latest 스킨파일을 다음과 같이 만들었는데요 :
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
list($height, $row_cnt, $cut_len) = explode(",", $options);
$all_cnt = 0;
?>
<table width="250px" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5"></td>
<td height="23"><img src="<?=$latest_skin_path?>/img/board_icon1.gif" align="absmiddle"> <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font color="#342B23"><?=$board[bo_subject]?></fpnt></a></strong></td>
<td align="right"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/more_img.gif" border="0" align="bottom"></a></td>
<td width="5"></td>
</tr>
<tr>
<td colspan=4 height="1" bgcolor="#d7d7d7"></td>
</tr>
<tr>
<td colspan=4 height="0" bgcolor="#f2f2f2"></td>
</tr>
</table>
</td>
</tr>
<!-- 최신글 목록 -->
<tr>
<td align="center">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<? for ($i=0; $i<count($list)/$row_cnt; $i++) { ?>
<td>
<table border="0" cellpadding="0" cellspacing="4"><tr><td align="center" valign="middle">
<?
$title = get_text($list[$all_cnt][wr_subject]);
$author = get_text($list[$all_cnt][wr_name]);
$created = get_text($list[$all_cnt][datetime2]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
$stitle = cut_str($list[$all_cnt][subject],$cut_len,"...");
echo $list[$i][icon_reply] . " ";
echo "<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>";
//$image = urlencode($list[$all_cnt][file][0][file]); // 첫번째 파일이 이미지라면
if (preg_match("/\.(gif|jpg|png)$/i", $img)) {
echo "<img src='$img' width='71' height='71' border='0' align='absmiddle' title='\"$title ,\" $author || $created'>"; // 이미지크기
} else if (!file_exists($img) || !$list[$all_cnt][file][0][file]) {
echo "<img src='$latest_skin_path/img/no_image.gif' alt='이미지 없음' width='71' height='71' border='0' align='absmiddle' title='\"$title ,\" $author || $created'>"; }
$all_cnt++;
?>
</td></tr></table>
</td>
<? } ?>
</tr>
<tr><td bgcolor="#ececec" height="1" colspan="<?=count($list)/$row_cnt?>"></td></tr>
<? } ?>
</table></td>
</tr>
<? if (count($list) == 0) { ?><tr><td align=center height="50"><font color="#6A6A6A">게시물이 없습니다.</a></td></tr><? } ?>
</table>
-------------------------------------------------------------------------------------------------------------
developer.lib.php 가 다른 최근 게시물에는 잘 적용되는데, 이 갤러리 최근 게시물에는 먹히지가 않아요. 아예 게시물이 안나타나고요, 아마도 row 적용 부분에서 에러가 있는것 같은데, 4시간째 해매도 도통 해결방안을 못찾아내서 이렇게 부탁드립니다. 뭐가 문제인가요?
이거 완성되면 깔끔하게 정리해서 스킨으로 올리겠습니다~
<?
if (!defined('_GNUBOARD_')) exit;
// 랜덤게시물 추출
// extend 디렉토리에 developer.lib.php파일을 올린다
// random_latest("최신글스킨명", 테이블명, 불러올갯수, 제목길이);
function random_latest($skin_dir="", $bo_table, $rows=10, $subject_len=40)
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$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 order by rand() desc limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
-------------------------------------------------------------------------------------------------------------
갤러리를 불러오는 latest 스킨파일을 다음과 같이 만들었는데요 :
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
list($height, $row_cnt, $cut_len) = explode(",", $options);
$all_cnt = 0;
?>
<table width="250px" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5"></td>
<td height="23"><img src="<?=$latest_skin_path?>/img/board_icon1.gif" align="absmiddle"> <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font color="#342B23"><?=$board[bo_subject]?></fpnt></a></strong></td>
<td align="right"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/more_img.gif" border="0" align="bottom"></a></td>
<td width="5"></td>
</tr>
<tr>
<td colspan=4 height="1" bgcolor="#d7d7d7"></td>
</tr>
<tr>
<td colspan=4 height="0" bgcolor="#f2f2f2"></td>
</tr>
</table>
</td>
</tr>
<!-- 최신글 목록 -->
<tr>
<td align="center">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<? for ($i=0; $i<count($list)/$row_cnt; $i++) { ?>
<td>
<table border="0" cellpadding="0" cellspacing="4"><tr><td align="center" valign="middle">
<?
$title = get_text($list[$all_cnt][wr_subject]);
$author = get_text($list[$all_cnt][wr_name]);
$created = get_text($list[$all_cnt][datetime2]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
$stitle = cut_str($list[$all_cnt][subject],$cut_len,"...");
echo $list[$i][icon_reply] . " ";
echo "<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>";
//$image = urlencode($list[$all_cnt][file][0][file]); // 첫번째 파일이 이미지라면
if (preg_match("/\.(gif|jpg|png)$/i", $img)) {
echo "<img src='$img' width='71' height='71' border='0' align='absmiddle' title='\"$title ,\" $author || $created'>"; // 이미지크기
} else if (!file_exists($img) || !$list[$all_cnt][file][0][file]) {
echo "<img src='$latest_skin_path/img/no_image.gif' alt='이미지 없음' width='71' height='71' border='0' align='absmiddle' title='\"$title ,\" $author || $created'>"; }
$all_cnt++;
?>
</td></tr></table>
</td>
<? } ?>
</tr>
<tr><td bgcolor="#ececec" height="1" colspan="<?=count($list)/$row_cnt?>"></td></tr>
<? } ?>
</table></td>
</tr>
<? if (count($list) == 0) { ?><tr><td align=center height="50"><font color="#6A6A6A">게시물이 없습니다.</a></td></tr><? } ?>
</table>
-------------------------------------------------------------------------------------------------------------
developer.lib.php 가 다른 최근 게시물에는 잘 적용되는데, 이 갤러리 최근 게시물에는 먹히지가 않아요. 아예 게시물이 안나타나고요, 아마도 row 적용 부분에서 에러가 있는것 같은데, 4시간째 해매도 도통 해결방안을 못찾아내서 이렇게 부탁드립니다. 뭐가 문제인가요?
이거 완성되면 깔끔하게 정리해서 스킨으로 올리겠습니다~
댓글 전체
갤러리 첨부 파일이 있는 형태인데
latest() 등에서 select로는 가져오지 않습니다.
list() 만드는 loop에서 get_file()을 한 번 해 주거나
latest.skin.php loop에서 get_file()하거나 해야 합니다.
bbs/list.php에서 get_file() 부르는 부분 참고하세요.
latest() 등에서 select로는 가져오지 않습니다.
list() 만드는 loop에서 get_file()을 한 번 해 주거나
latest.skin.php loop에서 get_file()하거나 해야 합니다.
bbs/list.php에서 get_file() 부르는 부분 참고하세요.
오오 역시... 감사합니다! 잘못된데를 계속 파고있었네요... latest.skin.php loop 에서 get_file() 을 하려면 어떻게 하나요? ㅡ0ㅡ;; $img_array = get_file($list[$all_cnt][file][0][file]) 해주면 되나요? 영 초보라서 OTL
라이브러리에서
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$list_img[$i] = get_file($row, $board, $latest_skin_path, $subject_len);
이부분을 추가해줬는데, get_file() 을 쓰는 방법을 몰라서.... 크큭;;; 그냥 get_file() 인가요?
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$list_img[$i] = get_file($row, $board, $latest_skin_path, $subject_len);
이부분을 추가해줬는데, get_file() 을 쓰는 방법을 몰라서.... 크큭;;; 그냥 get_file() 인가요?
아, 그리고 list.php 를 보니 get_file 이 없는데요?
bbs/list.php: 116
$list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);
common.php: 264
// 게시물 정보($write_row)를 출력하기 위하여 $list로 가공된 정보를 복사 및 가공
function get_list($write_row, $board, $skin_path, $subject_len=40)
이 함수 끝 부분에 get_file() 이 있습니다.
$list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);
common.php: 264
// 게시물 정보($write_row)를 출력하기 위하여 $list로 가공된 정보를 복사 및 가공
function get_list($write_row, $board, $skin_path, $subject_len=40)
이 함수 끝 부분에 get_file() 이 있습니다.