갤러리 최신글 랜덤으로 나오게 하는법 좀 알려주세요 ㅜㅜ > 그누4 질문답변

그누4 질문답변

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

갤러리 최신글 랜덤으로 나오게 하는법 좀 알려주세요 ㅜㅜ 정보

갤러리 최신글 랜덤으로 나오게 하는법 좀 알려주세요 ㅜㅜ

본문

제가 지금 사용하고 있는 최근게시물인데요....
글을 올리면 순차적으로 그냥 정상적으로 뽑아주는 일반적인 최신글입니다.
그런데. 이거를  랜덤으로 최신글로 뽑으려면 어떻게 해야하죠??
고수님들 부탁드립니다..
 
 
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$cols  = 4; //  이미지 가로갯수 //  이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h  = 1; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
?>
<style type="text/css">
<!--
.data  { font-family:돋움; font-size:8pt; color:#999999; }
-->
</style>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!-- 최신글 제목 -->
<tr><td>
 
</td></tr>
 

<td align='center'>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="5" align="center" valign='top'></td>
  </tr>
  <tr>
<? for ($i=0; $i<count($list); $i++) {
  if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td width="<?=$col_width?>%" valign='top'>
<?
$image = $list[$i][file][0][file]; //원본
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];
  if ( file_exists($thumb) )
 $img = $thumb;
 
    $style = "font-family:돋움; font-size:9pt; color:#636363;";
    if ($list[$i][icon_new])
    $style = "style='font-family:돋움; font-size:9pt; color:#006F00;' ";
 $subject = "<span $style>".cut_str($list[$i][subject],15)."</span>"; //제목 글자수 자르기
 $bg = "";  //새글?
    if ($list[$i][icon_new])
        $bg="la_top_2.gif";
     else
        $bg="la_top_1.gif";
     echo $list[$i][icon_reply] . " ";
  echo "<table width='100' cellpadding='0' cellspacing='0' border='0'>";
           if (preg_match("/\.(gif|jpg|png)$/i", $image)) {  
  echo "  <tr><td valign='top' align='center'><a href='{$list[$i]['href']}'><img src='$img' width='90' height='133' border='0'></a></td></tr>";
     } else
         echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/no_image.gif' width='90' height='133' border=0>";        
  echo "  <tr><td height='0'><a href='{$list[$i]['href']}'></a></td></tr></table>";
?></td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
    echo "<td width=$col_width%> </td>";
}
?>
  <? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
  </tr>
</table></td>
</tr>
</table>
<script language="javascript">
function popupImage(imageURL){
imageHandle=open("","popupForImage","toolbar=no,location=no,status=no,manubar=no,scrollbars=no,resizable=no,width=100,height=100,top=0,left=0");
  imageHandle.document.write("<title>   </title>");
  imageHandle.document.write("<style>");
  imageHandle.document.write("*{margin:0;padding:0;border:0;}");
  imageHandle.document.write("</style>");
  imageHandle.document.write("<img src=\""+imageURL+"\" onload=\"window.resizeTo(this.width+6,this.height+55);\" onclick=\"self.close();\" style=\"cursor:hand;\" title=\"클릭하면 닫힙니다.\">");
}
</script>
 
 
 
 
 
 
  • 복사

댓글 전체

latest_random.php 파일을
extend 폴더에 넣습니다.


latest_random.php ----------------------
<?
if (!defined('_GNUBOARD_')) exit;
// 랜덤게시물 추출
// 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;
}
?>



호출
<?=random_latest('in_latest','gallery', 4, 30); ?>


latest.skin.php 파일은 수정없습니다.
© SIRSOFT
현재 페이지 제일 처음으로