최신글에서 여분필드항목 글자수 자르기 질문 드립니다. 정보
최신글에서 여분필드항목 글자수 자르기 질문 드립니다.
본문
예전에 최신글 관련 똑같은 글을 올렸었는데, 오달수님 덕분에 잘 해결되었었습니다.
그런데 이번에는 최신글 소스를 유아원님의 [최신글] 이미지 체인지 이용하여 저에게 맞게 좀 수정을 하였습니다.
역시 이번에도 게시판에 여분필드를 이용하여 항목을 추가 시킨 상태입니다.
그런데 이소스는 기존에 제가 사용하던 소스와 항목을 불러오는것이 약간 틀리네요.
예전에는 제가 사용하던 최신글 소스중 항목의 내용을 불러오고 글자수 자르는것은
<?=cut_str($list[$i][subject],25,"...");?>
<?=cut_str($list[$i][wr_1],10,"...");?>
<?=cut_str($list[$i][wr_2],10,"...");?>
<?=cut_str($list[$i][wr_3],10,"...");?>
<?=cut_str($list[$i][wr_2],10,"...");?>
<?=cut_str($list[$i][wr_3],10,"...");?>
이런 식이었는데...
유아원님의 소스는 아래와 같습니다.
{$list[$i][subject]}
{$list[$i][wr_2]}
{$list[$i][wr_3]}
{$list[$i][wr_2]}
{$list[$i][wr_3]}
물론
<?=cut_str($list[$i][wr_3],10,"...");?> 를
{$list[$i][wr_3]} 처럼 바꿔주면 그 내용이 잘 나오기는 하는데...
문제는 위에도 말씀 드렸듯이 각 항목의 글자자르기가 되지를 않습니다.
{$list[$i][wr_3],10,"..."} 이렇게 바꾸어도 에러나고...
{$list[$i][wr_3],10,...} 이렇게 바꾸어도 에러나고...
{$list[$i][wr_3],10} 이렇게 바꾸어도 에러가 나네요.
이부분좀 알려주시면 정말 감사하겠습니다.
아래는 제가 사용하고 있는 소스입니다.
===================================================================
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if (!$board[bo_3]) alert("해당 게시판 설정 : 여분 필드 3 에 목록에서 보여질 이미지의 가로사이즈를 입력하십시오.");
if (!$board[bo_4]) alert("해당 게시판 설정 : 여분 필드 4 에 목록에서 보여질 이미지의 세로사이즈를 하십시오.");
if (!$board[bo_5]) alert("해당 게시판 설정 : 여분 필드 5 에 목록에서 보여질 이미지의 바뀌는 시간을 입력하십시오. (1초는 1000, 2초는 2000)");
if (!$board[bo_9]) alert("해당 게시판 설정 : 여분 필드 9 에 목록에서 보여질 이미지의 질(quality)을 비율로 설정하십시오. (100 이하)");
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 스킨 입니다.");
if (!$board[bo_4]) alert("해당 게시판 설정 : 여분 필드 4 에 목록에서 보여질 이미지의 세로사이즈를 하십시오.");
if (!$board[bo_5]) alert("해당 게시판 설정 : 여분 필드 5 에 목록에서 보여질 이미지의 바뀌는 시간을 입력하십시오. (1초는 1000, 2초는 2000)");
if (!$board[bo_9]) alert("해당 게시판 설정 : 여분 필드 9 에 목록에서 보여질 이미지의 질(quality)을 비율로 설정하십시오. (100 이하)");
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 스킨 입니다.");
$data_path = $g4['path'] . "/data/file/$bo_table";
$thumb_path = $data_path.'/thumb{$board[bo_3]}';
$thumb_path = $data_path.'/thumb{$board[bo_3]}';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
@chmod($thumb_path, 0707);
$sec_delay = $board[bo_5];
?>
?>
<!-- <?=$board[bo_subject]?> (<?=$board[bo_table]?>) 최신글 -->
<table width=305 height=100 cellpadding="0" cellspacing="0" border="0" align="center">
<tr><td align="center">
<?
for ($i=0; $i<count($list); $i++)
{
<table width=305 height=100 cellpadding="0" cellspacing="0" border="0" align="center">
<tr><td align="center">
<?
for ($i=0; $i<count($list); $i++)
{
$img = "<img src='$latest_skin_path/img/no_image.gif' border=0 title='이미지 없음'>";
$filename = $list[$i]['file'][0]['file'];
$thumb = $thumb_path.'/' . $filename;
if (!file_exists($thumb))
$filename = $list[$i]['file'][0]['file'];
$thumb = $thumb_path.'/' . $filename;
if (!file_exists($thumb))
{
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $board[bo_3] / $size[0];
$height = (int)($size[1] * $rate);
$height = (int)($size[1] * $rate);
if ($height < $board[bo_4])
$dst = imagecreatetruecolor($board[bo_3], $height);
else
$dst = imagecreatetruecolor($board[bo_3], $board[bo_4]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_3], $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/' . $filename, $board[bo_9]);
chmod($thumb_path.'/' . $filename, 0606);
}
}
$dst = imagecreatetruecolor($board[bo_3], $height);
else
$dst = imagecreatetruecolor($board[bo_3], $board[bo_4]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_3], $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/' . $filename, $board[bo_9]);
chmod($thumb_path.'/' . $filename, 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' border=0>";
$img = "<img src='$thumb' border=0>";
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
$body_data = "
<table id=id_s".$i." style='display:none' border='0' cellpadding='0' cellspacing='0' align='center' width=305 height=100>
<tr>
<td style='border:1px solid #E8E6DB; padding:0px;' width=130 height=100 align=center valign=middle><a href='{$list[$i][href]}' onfocus='this.blur()'>{$img}</a></td>
<table id=id_s".$i." style='display:none' border='0' cellpadding='0' cellspacing='0' align='center' width=305 height=100>
<tr>
<td style='border:1px solid #E8E6DB; padding:0px;' width=130 height=100 align=center valign=middle><a href='{$list[$i][href]}' onfocus='this.blur()'>{$img}</a></td>
<td style='padding:3 0 3 0px;' valign='middle' class='sub' height='100' width=10></td>
<td style='padding:3 0 3 0px;' valign='middle' class='sub' height='100' width=165>
항목1 : <br>
<a href='{$list[$i][href]}'>{$list[$i][subject]}</a><br>
항목2 : <br>
<a href='{$list[$i][href]}'>{$list[$i][wr_2]}</a><br>
항목3 :<br>
<a href='{$list[$i][href]}'>{$list[$i][wr_3]}</a>
항목1 : <br>
<a href='{$list[$i][href]}'>{$list[$i][subject]}</a><br>
항목2 : <br>
<a href='{$list[$i][href]}'>{$list[$i][wr_2]}</a><br>
항목3 :<br>
<a href='{$list[$i][href]}'>{$list[$i][wr_3]}</a>
</td>
</tr>
</table>
";
echo $body_data;
}
?>
</tr>
</table>
";
echo $body_data;
}
?>
</td></tr>
</table>
</table>
<script language='JavaScript'>
var oldshow = 1;
var showid = 1;
function ssh_init() {
eval("document.all.id_s"+oldshow+".style.display='none'");
eval("document.all.id_s"+showid+".style.display='block'");
var oldshow = 1;
var showid = 1;
function ssh_init() {
eval("document.all.id_s"+oldshow+".style.display='none'");
eval("document.all.id_s"+showid+".style.display='block'");
oldshow = showid;
showid++;
if (showid><?=$i-1?>) showid=0;
if (showid><?=$i-1?>) showid=0;
setTimeout("ssh_init()", <?=$sec_delay?>);
}
</script>
}
</script>
<script language='JavaScript'>
<? if (count($list)>0){ echo "ssh_init();"; } ?>
</script>
<? if (count($list)>0){ echo "ssh_init();"; } ?>
</script>
댓글 전체
$body_data = " <---이줄 바로위에
$test=cut_str($list[$i][wr_3],10,'...');
이렇게 넣어서 문자열자른것을 $test에 넣어둔후,
$body_data = ".....................중략......................
<a href='{$list[$i][href]}'>{$test}</a><br>"; 이렇게 넣으세요.
.....................중략......................
echo $body_data;
$test=cut_str($list[$i][wr_3],10,'...');
이렇게 넣어서 문자열자른것을 $test에 넣어둔후,
$body_data = ".....................중략......................
<a href='{$list[$i][href]}'>{$test}</a><br>"; 이렇게 넣으세요.
.....................중략......................
echo $body_data;

김범식님 정말 정말 감사합니다.
이것때문에 전전긍긍하고 있었는데, 깜끔하게 해결되었습니다.
다시한번 진심으로 감사드립니다.
이것때문에 전전긍긍하고 있었는데, 깜끔하게 해결되었습니다.
다시한번 진심으로 감사드립니다.

항목1 : <br>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_subject],30,'...')."</a><br>
항목2 : <br>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_2],10,'...')."</a><br>
항목3 :<br>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_3],10,'...')."</a>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_subject],30,'...')."</a><br>
항목2 : <br>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_2],10,'...')."</a><br>
항목3 :<br>
<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_3],10,'...')."</a>
아 그렇군요..
음...