갤러리 내용출력 글자 자르기 > 그누4 질문답변

그누4 질문답변

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

갤러리 내용출력 글자 자르기 정보

갤러리 내용출력 글자 자르기

본문

갤러리 스킨을 이용하고 있습니다.
리스트 부분에 본문내용을 출력하려고 합니다.
그래서 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>";
    $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;
            $rate = $board[bo_1] / $size[0];
            $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);
        }
    }
    if (file_exists($thumb))
        $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>";
    $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>";
    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";
}
// 나머지 td
$cnt = $i%$mod;
if ($cnt)
    for ($i=$cnt; $i<$mod; $i++)
        echo "<td width='{$td_width}%'> </td>";
?>

댓글 전체

루트님 답변 감사합니다. 그런데 적용해보니 아무것도 출력이 안됩니다. 혹시나 해서 따옴표를 넣었더니 바로 에러가 나네요 ㅎㅎㅎ.
다시 한 번 부탁드립니다.
루트님의 코드를
$wr_content = "<span $style>". $list[$i][wr_content] ."</span>";
이후에 넣으셔야 합니다...기존거를 유지하시구요 그런데 이방법에 문제점은 입력된내용이 html에디터나 html코드를 포함하고 있으면 이상하게 깨질수도 있다는거죠;;
stip_tags 류의 명령으로 태그를 html태그류를 무력화 시킨후 자르시거나 해야할것 같습니다...물론 html코드류들이 안들어 가있다면 상관없습니다...오히려 nl2br로 줄바꿈에쪽에 신경을 쓰셔야 하겠지요
전체 26 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT