s

갤러리 최신글 가로 숫자 지정 방법

· 2013-06-18 (화) 19:39:34 · 1687 · 4
도와 주십시요
dosol.or.kr 입니다.
메인 페이지에 현재 이미지 섬네일이 가로 3개 나타나고 있습니다.
이를 가로 4개 세로 2줄로 나타나게 하고 싶습니다.
어떤 분이 도움 주셨는데 잘 안되네요.
아시는 분 도움 부탁드립니다.
메인에 넣은 소스입니다.


<?
echo latest("gallery", "dosol_photo", 8, 15); // basic 스킨으로 free 라는 게시판을 출력합니다.
?>

많은 도움 부탁드립니다.
|

댓글 4개

최신글의 출력 갯수는 해당 페이지(/index.php)에서 latest 함수에서 처리가능합니다.
<?
// 사용방법
// latest(스킨, 게시판아이디, 출력라인, 글자수);
echo latest("basic", $row['bo_table'], 10, 70);
?>


이미지의 가로갯수 즉 한줄에 몇개를 출력할지는 스킨페이지에서 처리가능합니다.
/skin/latest/스킨명/latest.skin.php 에서 처리하시면 되구요.
for 문 안쪽에

아래처럼 처리하심됩니다.
if ( $i % 2 == 0 ) {
// 줄바뀜 처리
}
//이미지출력

% 는 $i 값을 2로 나누었을때 나머지값을 구하는 연산자이고
2 값은 가로 2번째에서 아래로 내린다는거고
0 값은 나머지값이 0 그러니까 2값으로 나누었을때 나머지 입니다.
gallery 라는 스킨 소스를 올려야 답변을 할 수 있습니다
latest.skin.php 입니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

include_once("$latest_skin_path/skin.lib.php");

if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

if (!$board[bo_3]) {
$board[bo_3] = "66";
$sql = " update $g4[board_table] set bo_3 = '$board[bo_3]', bo_3_subj = '최신글 가로 픽셀' where bo_table = '$bo_table' ";
sql_query($sql);
}

if (!$board[bo_4]) {
$board[bo_4] = "46";
$sql = " update $g4[board_table] set bo_4 = '$board[bo_4]', bo_4_subj = '최신글 세로 픽셀' where bo_table = '$bo_table' ";
sql_query($sql);
}
?>

<style>
ul.list{clear:both;margin:0;padding:0;margin-top:15px;}
ul.list li{float:left;width:25%;height:96px;color:#666;text-align:center;}
ul.list img{border:1px solid #dfdfdf;}
ul.list p{margin-top:8px;line-height:1.2em;}
ul.list a{color:#666;}
ul.list a:hover{color:#666;}
ul.list a:visited{color:#666;}
</style>
<!---
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<td width=14><img src='<?=$latest_skin_path?>/img/latest_t01.gif'></td>
<td width='100%' background='<?=$latest_skin_path?>/img/bg_latest.gif'>  <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><?=$board[bo_subject]?></a></strong></td>
<td width=37 background='<?=$latest_skin_path?>/img/bg_latest.gif'><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/more.gif' border=0></a></td>
<td width=14><img src='<?=$latest_skin_path?>/img/latest_t02.gif'></td>
</tr>
</table>--->

<ul class="list">
<? for ($i=0; $i<count($list); $i++) { ?>
<li>
<?
echo $list[$i]['icon_reply'] . " ";
echo "<a href='{$list[$i]['href']}'>";
echo makeThumbs($g4[path]."/data/file/$bo_table", $list[$i][file][0][file], $board[bo_3], $board[bo_4], cut_str($list[$i][subject],20), $latest_skin_path);
echo "</a>";
echo "<p>";
echo "<a href='{$list[$i]['href']}'>";
if ($list[$i]['is_notice'])
echo "<font style='font-family:돋움; font-size:9pt; color:#2C88B9;'><strong>{$list[$i]['subject']}</strong></font>";
else
echo "{$list[$i]['subject']}";
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>";
echo "</p>";

// 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'];
?>
</li>
<? } ?>

<? if (count($list) == 0) { ?><li><font color=#6A6A6A>게시물이 없습니다.</font></li><? } ?>

</ul>

skin.lip.php 입니다.

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

if (!function_exists("makeThumbs")) {

function makeThumbs($oriPath, $oriFileName, $thmWidth="", $thmHeight="", $thmAlt="", $latest_skin_path) {
global $g4;

$errorFilePrt = "<img src=\"".$latest_skin_path."/img/noimage.gif\" width=\"".$thmWidth."\" height=\"".$thmHeight."\" border=\"0\" alt=\"이미지 없음\" />";

$oriFile = $oriPath . "/" . $oriFileName;
if (is_file($oriFile) == false) return $errorFilePrt; // 원본 부재

$thmPath = $oriPath . "/thumbs_latest";
$thmFile = $thmPath . "/" . $oriFileName;

$oriSize = getimagesize($oriFile);
$oriWidth = $oriSize[0];
$oriHeight = $oriSize[1];
$oriType = $oriSize[2];

if ($oriType > 3) return $errorFilePrt; // 원본 이미지 타입 오류

$oriRate = $oriWidth / $oriHeight;

if ($thmWidth == "" && $thmHeight == "") return $errorFilePrt; // 썸네일 사이즈 미지정

if ($thmWidth == "") $thmWidth = $thmHeight * $oriRate;
if ($thmHeight == "") $thmHeight = $thmWidth / $oriRate;

$widthRate = $thmWidth / $oriWidth;
$heightRate = $thmHeight / $oriHeight;

$oriFilePrt = "<img src=\"".$oriFile."\" width=\"".$oriWidth."\" height=\"".$oriHeight."\" border=\"0\" alt=\"".$thmAlt."\" />";

if ($widthRate >= 1 && $heightRate >= 1) return $oriFilePrt; // 리사이징 불필요

if (file_exists($thmFile)) { // 썸네일 유무

$fp = fopen($thmFile, "r");
$fstat = fstat($fp);
$thmFileTime = $fstat['ctime'];
fclose($fp);

$fp = fopen($oriFile, "r");
$fstat = fstat($fp);
$oriFileTime = $fstat['ctime'];
fclose($fp);

if (is_dir($oriPath . "/thumbs_latest/")) {
$array1 = $array2 = array();
if ($dh = opendir($oriPath . "/thumbs_latest/")) {
while (($file = readdir($dh)) !== false) {
$array1[] = $file;
}
closedir($dh);
}
if ($dh = opendir($oriPath . "/")) {
while (($file = readdir($dh)) !== false) {
$array2[] = $file;
}
closedir($dh);
}
$array_diff = array_diff($array1, $array2);
foreach ($array_diff as $k => $v) {
if (is_file($oriPath . "/thumbs_latest/" . $v)) @unlink($oriPath . "/thumbs/" . $v);
}
}

$thmFileSize = getimagesize($thmFile);

if ($thmWidth == $thmFileSize[0] && $thmHeight == $thmFileSize[1]) { // 썸네일 갱신 불필요
if ($thmFileTime > $oriFileTime) {
$thmSize = getimagesize($thmFile);
$thmFilePrt = "<img src=\"".$thmFile."\" width=\"".$thmSize[0]."\" height=\"".$thmSize[1]."\" border=\"0\" alt=\"".$thmAlt."\" />";
return $thmFilePrt;
}
}

}

@unlink($thmFile);
@mkdir($thmPath);
@chmod($thmPath, 0707);

if ($widthRate < $heightRate) {
$tempWidth = (int)($oriWidth * $heightRate);
$tempHeight = $thmHeight;
} else {
$tempWidth = $thmWidth;
$tempHeight = (int)($oriHeight * $widthRate);
}

if ($tempWidth == "") $tempWidth = $thmWidth;
if ($tempHeight == "") $tempHeight = $thmHeight;

switch($oriType) {
case(1) :
if(function_exists('imagecreateFromGif')) $tempImage = imagecreateFromGif($oriFile);
break;
case(2) :
if(function_exists('imagecreateFromJpeg')) $tempImage = imagecreateFromJpeg($oriFile);
break;
case(3) :
if(function_exists('imagecreateFromPng')) $tempImage = imagecreateFromPng($oriFile);
break;
}

if ($tempImage) {
if (function_exists('imagecreatetruecolor')) {
$tempCanvas = imagecreatetruecolor($thmWidth, $thmHeight);
} else {
$tempCanvas = imagecreate($thmWidth, $thmHeight);
}

if (function_exists('imagecopyresampled')) {
imagecopyresampled($tempCanvas, $tempImage, 0, 0, 0, 0, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));
} else {
imagecopyresized($tempCanvas, $tempImage, 0, 0, 0, 0, $tempWidth, $tempHeight, ImageSX($tempImage), ImageSY($tempImage));
}
ImageDestroy($tempImage);
ImageJpeg($tempCanvas, $thmFile, 100);
ImageDestroy($tempCanvas);
unset($tempImage, $tempCanvas);
}

$thmFilePrt = "<img src=\"{$thmFile}\" width=\"{$thmWidth}\" height=\"{$thmHeight}\" border=\"0\" alt=\"{$thmAlt}\" />";

return $thmFilePrt;
}
}
?>
이 소스처럼 해서 원하는 갯수만큼 출력하려는 것은 조금 문제가 있어 보입니다
어쨌던 아래 부분에서 25%를 ->24->23 등으로 바꾸어 가면서 해보세요

ul.list li{float:left;width:25%;height:96px;color:#666;text-align:center;}
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
13-06-19 조회 1,152
13-06-18 조회 2,337
13-06-18 조회 1,644
13-06-18 조회 1,088
13-06-18 조회 1,168
13-06-18 조회 1,659
13-06-18 조회 1,083
13-06-18 조회 1,688
13-06-18 조회 1,909
13-06-18 조회 1,084
13-06-18 조회 1,086
13-06-18 조회 1,103
13-06-18 조회 1,672
13-06-18 조회 978
13-06-18 조회 1,131
13-06-18 조회 1,130
13-06-18 조회 893
13-06-18 조회 1,094
13-06-18 조회 1,092
13-06-18 조회 1,832