2개 게시판에서 최신글 뽑아내고 싶어요~~ 채택완료
보통 최신글의 경우 1개의 게시판이나 그룹게시판에서 최신글을 뽑아오는데요.
그런데요. 저는 게시판 2개 또는 3개 에서 최신글을 뽑아 오고싶은데요...
아래 코드중 어느부분을 수정하면 가능할까요?
(랜덤 최신글 lib 코드입니다.)
?> //*******************************************************************************/ //랜덤게시물 추출 방법 function r_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; } ?>
답변 2개
감사합니다~~^ ^
덕분에 썸네일 없는 최신글 형식에서는 잘 표현되어지네요.^^*
그런데요.
썸네일 있는 최신글에서는 오류가 나오더라구요...ㅡㅡ;
latest.skin.php on line 22 에 에러가 있다고 하면서요^^*
그래서 아래 최신글 코드가 있는데요..
어떻게 하면 썸네일을 가져올수 있을가요?
</p><p style="margin-left: 40px;"><? </p><p style="margin-left: 40px;">$thumbx = 150;
$thumby = 150;</p><p style="margin-left: 40px;">$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/latest_thumb'; // 썸네일 생성 폴더명</p><p style="margin-left: 40px;">@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);</p><p style="margin-left: 40px;">?></p><p style="margin-left: 40px;"><table width="100%" border="0" cellspacing="0" >
<tr>
<td colspan=10>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<? for($i=0; $i<count($list); $i++) {$m++;
$file_name = get_thumb_filename2($list[$i][wr_id], 0);</p><p style="margin-left: 40px;">$thumb = $thumb_path.'/'.$list[$i][wr_id];</p><p style="margin-left: 40px;">$file = "$g4[path]/data/file/$bo_table/".$list[$i][file][0][file];
//$destfile = $file.'_gga_gd_latest_Thumb';
$destfile = $thumb_path.'/'.$list[$i][wr_id];
$size = @getimagesize($file);
if(is_array($size) && !is_file($destfile)) {
switch($size[2]) {
case(1) :
if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($file);
break;
case(2) :
if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($file);
break;
case(3) :
if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($file);
break;
}
$fixsize = gga_image_size($size[0], $size[1], $thumbx, $thumby);
if($im) {
if($i==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."$g4[path]/data/file/$bo_table/*reportThumb -rf");
if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
else $newim = ImageCreate($fixsize[x],$fixsize[y]);
if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
ImageDestroy($im);
ImageJpeg($newim, $destfile, 100);
ImageDestroy($newim);
unset($im, $newim);
}
$list[$i][img][x] = $fixsize[x];
$list[$i][img][y] = $fixsize[y];
} else {
if(is_file($destfile)) {
$size = @getimagesize($destfile);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
} else {
$file = "$latest_skin_path/img/noimage.gif";
$size = @getimagesize($file);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
}
}
if(is_file($destfile)) $file = $destfile;
if(time()-(60*60*24) <= strtotime($list[$i][wr_datetime])) $list[$i][date] = date('H:i',strtotime($list[$i][wr_datetime]));
else $list[$i][date] = date('Y.m.d',strtotime($list[$i][wr_datetime]));</p><p style="margin-left: 40px;">$file = str_replace('%', '%25', $file);</p><p style="margin-left: 40px;">?>
<td align="center" width=20%>
<table cellpadding="0" cellspacing="0" border="0" style="padding:0px;">
<tr><td height=15></td></tr>
<tr align=center>
<td style='padding-top:0px;'>
<table width="10" bgcolor='#ffffff' cellpadding="3" cellspacing="0" border="0">
<tr>
<td align="center" valign="middle"><a href="<?=$list[$i][href]?>"><img src="<?= $file?>" width="<?=$list[$i][img][x]?>" height="<?=$list[$i][img][y]?>" border="0" title="<?=$list[$i][wr_subject]?>" style='border:1px solid #cfcfcf'></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="middle" style='padding-top:3px;border:0px solid #777777'>
<a href="<?=$list[$i][href]?>"><?=$list[$i][subject]?></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>";?!-->
<!--?=$list[$i][icon_new]?!-->
</td>
</tr>
<tr><td height=15></td></tr>
</table>
</td>
<? if ($m%6==0){ //여기에서 줄바꾸기?></tr><tr><?}?>
<? } ?>
</tr>
</table>
</td></p><p style="margin-left: 40px;"><? if(!count($list)) echo("<td align='center' valign='middle' height='50'><font color='gray'>등록된 사진이 없습니다.</font></td>"); ?></p><p style="margin-left: 40px;"> </tr>
</table>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
덕분에 썸네일 없는 최신글 형식에서는 잘 표현되어지네요.^^*
그런데요.
썸네일 있는 최신글에서는 오류가 나오더라구요...ㅡㅡ;
latest.skin.phpon line22 에 에러가 있다고 하면서요^^*
그래서 아래 최신글 코드가 있는데요..
어떻게 하면 썸네일을 가져올수 있을가요?
[code]
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$thumbx = 150;
$thumby = 150;
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/latest_thumb'; // 썸네일 생성 폴더명
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<table width="100%" border="0" cellspacing="0" >
<tr>
<td colspan=10>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<? for($i=0; $i<count($list); $i++) {$m++;
$file_name = get_thumb_filename2($list[$i][wr_id], 0);
$thumb = $thumb_path.'/'.$list[$i][wr_id];
$file = "$g4[path]/data/file/$bo_table/".$list[$i][file][0][file];
//$destfile = $file.'_gga_gd_latest_Thumb';
$destfile = $thumb_path.'/'.$list[$i][wr_id];
$size = @getimagesize($file);
if(is_array($size) && !is_file($destfile)) {
switch($size[2]) {
case(1) :
if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($file);
break;
case(2) :
if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($file);
break;
case(3) :
if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($file);
break;
}
$fixsize = gga_image_size($size[0], $size[1], $thumbx, $thumby);
if($im) {
if($i==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."$g4[path]/data/file/$bo_table/*reportThumb -rf");
if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
else $newim = ImageCreate($fixsize[x],$fixsize[y]);
if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
ImageDestroy($im);
ImageJpeg($newim, $destfile, 100);
ImageDestroy($newim);
unset($im, $newim);
}
$list[$i][img][x] = $fixsize[x];
$list[$i][img][y] = $fixsize[y];
} else {
if(is_file($destfile)) {
$size = @getimagesize($destfile);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
} else {
$file = "$latest_skin_path/img/noimage.gif";
$size = @getimagesize($file);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
}
}
if(is_file($destfile)) $file = $destfile;
if(time()-(60*60*24) <= strtotime($list[$i][wr_datetime])) $list[$i][date] = date('H:i',strtotime($list[$i][wr_datetime]));
else $list[$i][date] = date('Y.m.d',strtotime($list[$i][wr_datetime]));
$file = str_replace('%', '%25', $file);
?>
<td align="center" width=20%>
<table cellpadding="0" cellspacing="0" border="0" style="padding:0px;">
<tr><td height=15></td></tr>
<tr align=center>
<td style='padding-top:0px;'>
<table width="10" bgcolor='#ffffff' cellpadding="3" cellspacing="0" border="0">
<tr>
<td align="center" valign="middle"><a href="<?=$list[$i][href]?>"><img src="<?= $file?>" width="<?=$list[$i][img][x]?>" height="<?=$list[$i][img][y]?>" border="0" title="<?=$list[$i][wr_subject]?>" style='border:1px solid #cfcfcf'></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="middle" style='padding-top:3px;border:0px solid #777777'>
<a href="<?=$list[$i][href]?>"><?=$list[$i][subject]?></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>";?!-->
<!--?=$list[$i][icon_new]?!-->
</td>
</tr>
<tr><td height=15></td></tr>
</table>
</td>
<? if ($m%6==0){ //여기에서 줄바꾸기?></tr><tr><?}?>
<? } ?>
</tr>
</table>
</td>
<? if(!count($list)) echo("<td align='center' valign='middle' height='50'><font color='gray'>등록된 사진이 없습니다.</font></td>"); ?>
</tr>
</table>
[/code]
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
아마도 get_thumb_filename2() 함수가 없어서 난 에러는 아닐까 싶습니다.
$file_name이 쓰이는데가 없으니 그냥 그 라인은 지우셔도 상관없을듯 보입니다.
그런데 썸네일이 있어도 원본이미지를 출력하는거 같습니다. img src를 $file 대신 $thumb 쓰시는게 맞을듯해요.