메인에 최신글 내용 추가

메인에 최신글 내용 추가

QA

메인에 최신글 내용 추가

답변 5

본문

홈페이지 메인에 최근 글의 내용과 썸네일을 함께 불러오고 싶습니다.

 

<?echo latest("pa", "preview", 2, 50)> 다음과 같은 코드로

pa 스킨으로 preview 게시판의 글을 2개 게시하며 글자 50자까지 노출되게 한다.

까지 이해했습니다(혹시 잘못이해 한 것이 있다면 지적 부탁드립니다)

 

그런데 내용 50자가 노출이 되지 않습니다.

제가 내린 결론으로는 pa skin에 내용 코드를 추가해줘야 할 것 같습니다.

전문 개발자가 아닌 일개 대학원생이라 그누보드에 대한 기반 지식이 부족합니다.

스킨 파일 코드에서 어디에 어떤 코드를 추가해야할 지 가르침 좀 부탁드립니다.

감사합니다.

 

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
$cols  = 1; //  이미지 가로갯수 //  이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h  = 1; // 이미지 상하 간격
$col_width = (int)(99 / $cols);
$img_width = 250; //썸네일 가로길이 
$img_height = 70; //썸네일 세로길이 
$img_quality = 100; //퀼리티 100이하로 설정 일부 php버전에서는 10이하의 수로 처리 될 수 있삼
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb_img_list'; //썸네일 이미지 생성 디렉토리
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<? for ($i=0; $i<count($list); $i++) { ?>
<?
$wr_content = "<a href='{$list[$i]['href']}'>".cut_str(strip_tags($list[$i]['wr_content']), 350, '...')."</a>";
 //   if ($i>0 && $i%$cols==0) { echo "<td colspan='$cols' height='$image_h'></td><tr>"; }
    $img = "<img src='$g4_path/img/noimage.gif' border=0 width='$img_width' height='$img_height' title='이미지 없음' align=left style='margin-right:5px; border:1 #222222 solid;'>";
    $thumb = $thumb_path.'/'.$list[$i][wr_id];
 
 
 // 섬네일과 새로 올린파일 날짜를 비교하여 셈네일을 갱신하기위해서 지운다.
 if ( file_exists($thumb) && (filemtime($thumb) < filemtime($list[$i][file][0][path] .'/'. $list[$i][file][0][file])) ) {
  @unlink($thumb);
 }
 
    // 썸네일 이미지가 존재하지 않는다면
    if (!file_exists($thumb)) {
        $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
        // 업로드된 파일이 이미지라면
  //echo $i;
        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 = $img_width / $size[0];
            $height = (int)($size[1] * $rate);
   $width = (int)($size[0] * $rate);
            // 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
            $dst = imagecreatetruecolor($img_width, $img_height);
            if ($height < $img_height) {                // 계산된 이미지 높이로 복사본 이미지 생성
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $img_height, $size[0], $size[1]);
    imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
            } else {   // 설정된 이미지 높이로 복사본 이미지 생성
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
    imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
   
   }
   //echo $i;
            chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
        }
    }
    if (file_exists($thumb))
        $img = "<img src='$thumb' border=0>";
?>
<?
        $datetime = substr($list[$i][wr_datetime],0,10); 
        $datetime2 = $list[$i][wr_datetime]; 
         
        if ($list[$i]['wr_datetime'] >= date("Y-m-d H:i:s", $g4['server_time'] - ($row['bo_new'] * 3600))) $comment_new = "new";
        if ($datetime == $g4[time_ymd]) 
            $datetime2 = substr($datetime2,11,5); 
        else 
            $datetime2 = substr($datetime2,5,5); 
   
    $list[$i][datetime] = $datetime; 
    $list[$i][datetime2] = $datetime2; 
    
    $a[$i] = array( 
      "wr_date"=>$datetime2,
);
?>
<?
 $rw_subject = cut_str(stripslashes($list[$i][subject]),$subject_size,'..');
 $a_link="<a href='{$list[$i][href]}'>$rw_subject</a>";
 $a_img="<a href='http://chem.yonsei.ac.kr/~injae/gnuboard4/bbs/preview3.php?bo_table=papers_2&wr_id={$list[$i][wr_id]}'>$img</a>";
 $a_comment="<a href=\"{$list[$i][comment_href]}\"><span class='commentFont'>{$list[$i]['comment_cnt']}</span></a>";
 $rw_content = cut_str(stripslashes($list[$i][wr_content]),$content_size,' ..more');
 $rw_content = strip_tags($rw_content);
 $a_content = cut_str(strip_tags($list[$i][wr_content]), 230, '...');
?>
<?=$a_img?>
<? 

echo "<br><a href='http://chem.yonsei.ac.kr/~injae/gnuboard4/bbs/preview3.php?bo_table=papers_2&wr_id={$list[$i][wr_id]}'><span style='font-size:10pt;font-family:tahoma;color:#4D5F85'><b>";
echo "".cut_str(strip_tags($list[$i]['wr_content']), 120, '...')."</b><br><br></a>"; 
?><? } ?>
<? echo "</a>"; ?>
<? echo "<img src='";?><?=$latest_skin_path?><? echo "/img/line.jpg'>"; ?> 

이 질문에 댓글 쓰기 :

답변 5

 $rw_subject = cut_str(stripslashes($list[$i][subject]),50,'..');

 $a_link="<a href='{$list[$i][href]}'>$rw_subject</a>";

 $a_img="<a href='http://chem.yonsei.ac.kr/~injae/gnuboard4/bbs/preview3.php?bo_table=papers_2&wr_id={$list[$i][wr_id]}'>$img</a>";

 $a_comment="<a href=\"{$list[$i][comment_href]}\"><span class='commentFont'>{$list[$i]['comment_cnt']}</span></a>";

 $rw_content = cut_str(stripslashes($list[$i][wr_content]),50,' ..more');

 

$subject_size, $content_siz 를 50으로 모두 바꾸고 한번 해보세요..  81라인부터네요.

 

그리고 이것도 안나오면 

$rw_subject = stripslashes($list[$i][subject]);
$rw_content = stripslashes($list[$i][wr_content]);
이렇게도 해보세요.

제한없이 출력하는 건데.. 이것도 안되면.. 전체코드를 봐야 할 듯 합니다... 

위 코드로만 보면...

85라인의 $rw_content = cut_str(stripslashes($list[$i][wr_content]),$content_size,' ..more'); 에서 content_size가 안보이는듯해요.. $content_size 를 50으로 해서 테스트해보세요.

댓글 감사합니다.
'..more' 대신'50'을 넣어도 내용은 안나오고, '50', $content_size='50' 등으로 바꾸었는데도 내용은 출력이 안됩니다.
+$content_size 자리 자체를 50으로 바꾸어보았습니다만 역시 안되네요

안된다는건 제목이 보여야할 자리에 공백으로 아무것도 안나온다는 이야기시죠?

흠.. 해결되셨다니 다행이네요.. 그 라인이 영향을 주지 않을거 같은데 해결이 되네요..^^;

폰트는 아시다시피 

font-family:tahoma; 

이 구문때문에 영향을 받습니다. 삭제하시면 페이지에 설정되는 폰트로 나올꺼에요.

답변을 작성하시기 전에 로그인 해주세요.
전체 2
© SIRSOFT
현재 페이지 제일 처음으로