최근게시물에 랜덤이미지 추출하는법 정보
최근게시물에 랜덤이미지 추출하는법본문
갤러리게시판에 있는 게시물을 랜덤으로
최근 게시물에 뿌리고 싶습니다.
latest.skin.php에 어디를 손봐야 하나요.
초보라 죄송합니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$arr_new_cols=3; //한 줄에 출력할 이미지 개수
$imgwidth = 300; //이미지 가로사이즈
$imgheigh = 200; //이미지 세로사이즈
$tablewidth = 1000; // 전체테이블사이즈
$top_title = 최강통합갤러리; // 상단제목 설정하세요
$data_path = $g4[path]."/data/file";
$thumb_path = $data_path."/thumb/"; //불당썸네일 경로
?>
<style type="text/css">
BODY,TD,SELECT,input,form,TEXTAREA,center,option,pre,blockquote,span {font-size:9pt; font-family:나눔고딕; color:#666666;line-height:140%;}
a {selector-dummy: expression(this.hideFocus=true);}
A:link {color:666666;text-decoration:none;}
A:visited {color:666666;text-decoration:none;}
A:active {color:666666;text-decoration:none;}
A:hover {color:30C0FF;text-decoration:none;}
.sml8 {font-size:8pt; font-family:돋움; color:#2080D0; letter-spacing:-1;line-height:140%;};
</style>
<script language="javascript" src="<?=$latest_skin_path?>/img/common.js"></script>
<script language="javascript" src="<?=$latest_skin_path?>/img/viewTitle.js" type="text/javascript"></script>
<table width="<?=$tablewidth?>" border=0 cellspacing=0 cellpadding=0 align=center>
<tr><td><img src=<?=$latest_skin_path?>/img/bul2.gif align=absmiddle>
<script type="text/javascript">showTitle("", "<?=$latest_skin_path?>/img/viewTitle2.swf", 550, 30, "<?=$top_title?>", "", "left", "0x343434");</script>
</td></td></tr>
<tr>
<td height=13 background=<?=$latest_skin_path?>/img/title_bg.gif></td>
</tr>
</table>
<br>
<table width="<?=$tablewidth?>" cellpadding=0 cellspacing=0 style="margin-top:7px;" align=center>
<tr>
<?
for ($i=0; $i<count($list); $i++) {
if ($i >= 0)
$title = get_text($list[$i][subject]);
//한 줄에 $arr_new_cols 만큼 출력
if($i%$arr_new_cols == 0 && $i>0)
echo "</tr><tr>";
$content = cut_str(get_text($list[$i][wr_content]), 80);
$bo_table=$board_list[$i][bo_table];
$image = urlencode($list[$i][file][0][file]); //이미지파일명
$thumb = $data_path."/".$bo_table."/".$image;
echo <<<HEREDOC
<td align='center'>
<a href='{$list[$i][href]}' >
<img src='$thumb' border='0' title='$title' class="img" width='$imgwidth' height='$imgheigh'></a>
<div><span class=sml8><a href=$g4[path]/bbs/board.php?bo_table={$board_list[$i][bo_table]}>[{$board_list[$i][bo_subject]}]</a></span><br><a href='{$list[$i][href]}' >{$subject} {$title}</a> {$list[$i][icon_new]}</div><br>
</td>
HEREDOC;
}
/* end for */
?>
<? if (count($list) == 0) { ?><td align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td><? } ?>
</tr>
</table>
최근 게시물에 뿌리고 싶습니다.
latest.skin.php에 어디를 손봐야 하나요.
초보라 죄송합니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$arr_new_cols=3; //한 줄에 출력할 이미지 개수
$imgwidth = 300; //이미지 가로사이즈
$imgheigh = 200; //이미지 세로사이즈
$tablewidth = 1000; // 전체테이블사이즈
$top_title = 최강통합갤러리; // 상단제목 설정하세요
$data_path = $g4[path]."/data/file";
$thumb_path = $data_path."/thumb/"; //불당썸네일 경로
?>
<style type="text/css">
BODY,TD,SELECT,input,form,TEXTAREA,center,option,pre,blockquote,span {font-size:9pt; font-family:나눔고딕; color:#666666;line-height:140%;}
a {selector-dummy: expression(this.hideFocus=true);}
A:link {color:666666;text-decoration:none;}
A:visited {color:666666;text-decoration:none;}
A:active {color:666666;text-decoration:none;}
A:hover {color:30C0FF;text-decoration:none;}
.sml8 {font-size:8pt; font-family:돋움; color:#2080D0; letter-spacing:-1;line-height:140%;};
</style>
<script language="javascript" src="<?=$latest_skin_path?>/img/common.js"></script>
<script language="javascript" src="<?=$latest_skin_path?>/img/viewTitle.js" type="text/javascript"></script>
<table width="<?=$tablewidth?>" border=0 cellspacing=0 cellpadding=0 align=center>
<tr><td><img src=<?=$latest_skin_path?>/img/bul2.gif align=absmiddle>
<script type="text/javascript">showTitle("", "<?=$latest_skin_path?>/img/viewTitle2.swf", 550, 30, "<?=$top_title?>", "", "left", "0x343434");</script>
</td></td></tr>
<tr>
<td height=13 background=<?=$latest_skin_path?>/img/title_bg.gif></td>
</tr>
</table>
<br>
<table width="<?=$tablewidth?>" cellpadding=0 cellspacing=0 style="margin-top:7px;" align=center>
<tr>
<?
for ($i=0; $i<count($list); $i++) {
if ($i >= 0)
$title = get_text($list[$i][subject]);
//한 줄에 $arr_new_cols 만큼 출력
if($i%$arr_new_cols == 0 && $i>0)
echo "</tr><tr>";
$content = cut_str(get_text($list[$i][wr_content]), 80);
$bo_table=$board_list[$i][bo_table];
$image = urlencode($list[$i][file][0][file]); //이미지파일명
$thumb = $data_path."/".$bo_table."/".$image;
echo <<<HEREDOC
<td align='center'>
<a href='{$list[$i][href]}' >
<img src='$thumb' border='0' title='$title' class="img" width='$imgwidth' height='$imgheigh'></a>
<div><span class=sml8><a href=$g4[path]/bbs/board.php?bo_table={$board_list[$i][bo_table]}>[{$board_list[$i][bo_subject]}]</a></span><br><a href='{$list[$i][href]}' >{$subject} {$title}</a> {$list[$i][icon_new]}</div><br>
</td>
HEREDOC;
}
/* end for */
?>
<? if (count($list) == 0) { ?><td align=center height=50><font color=#6A6A6A>게시물이 없습니다.</a></td><? } ?>
</tr>
</table>
댓글 전체
만약 최신글을 얻으신후 랜덤으로 돌리시려면
$rand_array = range( 0 , count($list));
shuffle($rand_array);
for ($n=0; $n<count($list); $n++) {
$i = $rand_array[$n];
으로 $i 값을 변경해 주시던가요
아니면 전체글에서 랜덤을 찾으시러면
lib/latest.lib.php 에
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
이분부의 order by 부분을
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by rand() limit 0, $rows ";
를 쓰시면 되고요
이렇게 하시면 테이블에 내용이 많아 지면 많이 느려지십니다
$rand_array = range( 0 , count($list));
shuffle($rand_array);
for ($n=0; $n<count($list); $n++) {
$i = $rand_array[$n];
으로 $i 값을 변경해 주시던가요
아니면 전체글에서 랜덤을 찾으시러면
lib/latest.lib.php 에
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
이분부의 order by 부분을
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by rand() limit 0, $rows ";
를 쓰시면 되고요
이렇게 하시면 테이블에 내용이 많아 지면 많이 느려지십니다
친절한 답변 감사드립니다.
그런데 rand_array로 했더니 약간의 문제가 발생하네요.
랜덤 추출은 되는데, 3열 방식으로 뽑아져하는데,
열자체도 랜덤으로 4열, 8열, 2열 ..... 이런식으로 나타나네요.
조금만 더 도움 부탁드립니다.
그런데 rand_array로 했더니 약간의 문제가 발생하네요.
랜덤 추출은 되는데, 3열 방식으로 뽑아져하는데,
열자체도 랜덤으로 4열, 8열, 2열 ..... 이런식으로 나타나네요.
조금만 더 도움 부탁드립니다.
$rand_array = range( 0 , count($list)-1); 로 하셔야 겠네요 ^^
그리고 죄송하지만
랜덤 추출은 되는데, 3열 방식으로 뽑아져하는데,
열자체도 랜덤으로 4열, 8열, 2열 ..... 이런식으로 나타나네요.
조금 이해가 안되서요 자세히 설명해 주실수 있을까요?
예를 들어 주시면 좋고요
그리고 죄송하지만
랜덤 추출은 되는데, 3열 방식으로 뽑아져하는데,
열자체도 랜덤으로 4열, 8열, 2열 ..... 이런식으로 나타나네요.
조금 이해가 안되서요 자세히 설명해 주실수 있을까요?
예를 들어 주시면 좋고요