갤러리 내용출력 글자 자르기 정보
갤러리 내용출력 글자 자르기본문
갤러리 스킨을 이용하고 있습니다.
리스트 부분에 본문내용을 출력하려고 합니다.
그래서 wr_content를 넣어 본문 출력을하였습니다.
그런데 본문이 길어서 보기가 싫습니다.
본문을 자르는 방법을 알고 싶습니다.
부탁드립니다.
아래는 제가 적용한 리스트 부분 소스입니다.
보시면 소스 아래 부분에
echo "<tr><td align=center width='150'>$wr_content</td></tr>";
부분이 본문출력 부분입니다.
부분이 본문출력 부분입니다.
부탁드립니다^^
<?
for ($i=0; $i<count($list); $i++)
{
if ($i && $i%$mod==0)
echo "</tr><tr>";
for ($i=0; $i<count($list); $i++)
{
if ($i && $i%$mod==0)
echo "</tr><tr>";
$img = "<img src='$board_skin_path/img/noimage.gif' border=0 width='$board[bo_1]' title='이미지 없음'>";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
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
break;
$thumb = $thumb_path.'/'.$list[$i][wr_id];
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
break;
$rate = $board[bo_1] / $size[0];
$height = (int)($size[1] * $rate);
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($board[bo_1], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_2]);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_2]);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' border=0>";
$img = "<img src='$thumb' border=0>";
$style = "";
if ($list[$i][icon_new])
$style = ""; // 읽지 않은 글?? style='font-weight:bold;' 추가
$subject = "<span $style>". $list[$i][subject] ."</span>";
$wr_content = "<span $style>". $list[$i][wr_content] ."</span>";
if ($list[$i][icon_new])
$style = ""; // 읽지 않은 글?? style='font-weight:bold;' 추가
$subject = "<span $style>". $list[$i][subject] ."</span>";
$wr_content = "<span $style>". $list[$i][wr_content] ."</span>";
$comment_cnt = "";
if ($list[$i][comment_cnt])
$comment_cnt = " <a href=\"{$list[$i][comment_href]}\"><span style='font-size:7pt;'>{$list[$i][comment_cnt]}</span></a>";
if ($list[$i][comment_cnt])
$comment_cnt = " <a href=\"{$list[$i][comment_href]}\"><span style='font-size:7pt;'>{$list[$i][comment_cnt]}</span></a>";
echo "<td width='{$td_width}%' valign=top style='word-break:break-all;'>";
echo "<table>";
echo "<tr><td height=5></td></tr>";
echo "<tr><td valign=top align=center width='150' height='113' style='width:150px;height:113px;border:1px solid #CCCCCC; padding:3px'><div style='width:150px; height:113px; position: relative; overflow:hidden;' align=center><a href='{$list[$i][href]}'>$img</a></div></td></tr>";
echo "<tr><td align=center width='150'><a href='{$list[$i][href]}'>$subject</a>{$comment_cnt}</td></tr>";
echo "<tr><td align=center width='150'>$wr_content</td></tr>";
if ($is_category) echo "<tr><td align=center><a href='{$list[$i][ca_name_href]}'><font color=#cccccc>[{$list[$i][ca_name]}]</font></a></td></tr>";
if ($is_checkbox) echo "<tr><td align=center><input type=checkbox name=chk_wr_id[] value='{$list[$i][wr_id]}'></td></tr>";
echo "<tr><td height=5></td></tr>";
echo "</table></td>\n";
}
echo "<table>";
echo "<tr><td height=5></td></tr>";
echo "<tr><td valign=top align=center width='150' height='113' style='width:150px;height:113px;border:1px solid #CCCCCC; padding:3px'><div style='width:150px; height:113px; position: relative; overflow:hidden;' align=center><a href='{$list[$i][href]}'>$img</a></div></td></tr>";
echo "<tr><td align=center width='150'><a href='{$list[$i][href]}'>$subject</a>{$comment_cnt}</td></tr>";
echo "<tr><td align=center width='150'>$wr_content</td></tr>";
if ($is_category) echo "<tr><td align=center><a href='{$list[$i][ca_name_href]}'><font color=#cccccc>[{$list[$i][ca_name]}]</font></a></td></tr>";
if ($is_checkbox) echo "<tr><td align=center><input type=checkbox name=chk_wr_id[] value='{$list[$i][wr_id]}'></td></tr>";
echo "<tr><td height=5></td></tr>";
echo "</table></td>\n";
}
// 나머지 td
$cnt = $i%$mod;
if ($cnt)
for ($i=$cnt; $i<$mod; $i++)
echo "<td width='{$td_width}%'> </td>";
?>
$cnt = $i%$mod;
if ($cnt)
for ($i=$cnt; $i<$mod; $i++)
echo "<td width='{$td_width}%'> </td>";
?>
댓글 전체
$wr_content=stripslashes(cut_str($wr_content, 100));
echo "<tr><td align=center width='150'>$wr_content</td></tr>";
echo "<tr><td align=center width='150'>$wr_content</td></tr>";
루트님 답변 감사합니다. 그런데 적용해보니 아무것도 출력이 안됩니다. 혹시나 해서 따옴표를 넣었더니 바로 에러가 나네요 ㅎㅎㅎ.
다시 한 번 부탁드립니다.
다시 한 번 부탁드립니다.
루트님의 코드를
$wr_content = "<span $style>". $list[$i][wr_content] ."</span>";
이후에 넣으셔야 합니다...기존거를 유지하시구요 그런데 이방법에 문제점은 입력된내용이 html에디터나 html코드를 포함하고 있으면 이상하게 깨질수도 있다는거죠;;
stip_tags 류의 명령으로 태그를 html태그류를 무력화 시킨후 자르시거나 해야할것 같습니다...물론 html코드류들이 안들어 가있다면 상관없습니다...오히려 nl2br로 줄바꿈에쪽에 신경을 쓰셔야 하겠지요
$wr_content = "<span $style>". $list[$i][wr_content] ."</span>";
이후에 넣으셔야 합니다...기존거를 유지하시구요 그런데 이방법에 문제점은 입력된내용이 html에디터나 html코드를 포함하고 있으면 이상하게 깨질수도 있다는거죠;;
stip_tags 류의 명령으로 태그를 html태그류를 무력화 시킨후 자르시거나 해야할것 같습니다...물론 html코드류들이 안들어 가있다면 상관없습니다...오히려 nl2br로 줄바꿈에쪽에 신경을 쓰셔야 하겠지요
그렇군요. 감사합니다^^ 일단 html코드를 배제해서 괜찮을 것 같은데. 다른데 적용하려면 좀더 봐야 겠네요.