테스트 사이트 - 개발 중인 베타 버전입니다

다중 게시판 최신글 추출 채택완료

이야기들 9년 전 조회 4,558
</strong></pre><pre><?php
// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)
function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='')
{

    global $g5;

    if (!$skin_dir) $skin_dir = 'basic';

    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
        if (G5_IS_MOBILE) {
            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            if(!is_dir($latest_skin_path))
                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        } else {
            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        }
        $skin_dir = $match[1];
    } else {
        if(G5_IS_MOBILE) {
            $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
        } else {
            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;
        }
    }

        $list = array();
        $sql_common = " from {$g5['board_new_table']} a  where find_in_set(a.bo_table, '{$bo_tables}')";
        $sql_common .= " and a.wr_id = a.wr_parent ";
        $sql_order = " order by a.bn_id desc ";
        $sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";

        $result = sql_query($sql);
        
        for ($i=0; $row=sql_fetch_array($result); $i++) {

            $sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";

          

            $board = sql_fetch($sql);

            $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];
            $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");



            $list[$i] = $row2;
            $list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);
            $list[$i]['bo_subject'] = $row['bo_subject'];
            $list[$i]['bo_table'] = $row['bo_table'];
        }

    ob_start();
    include $latest_skin_path.'/latest.skin.php';
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
<strong>

소스를 latest.lib.php 맨 아래에 추가 하고

 

적용할 곳에

 

</strong></p><p><font face="Courier New">echo</font> <code class="php plain">latest_all(</code><code class="php string">"basic"</code><code class="php plain">, </code><code class="php string">"notice,qna,news,faq"</code><code class="php plain">, 10, 20);</code></p><p><code class="php plain"><strong>


이렇게 추출을 했는데요.


일반게시판은 추출이 잘되는데요. 갤러리 게시판을 추출하면 내용은 잘 불러와 지는데 이미지가


불러와지질 않네요.


고수님들의 명쾌한 답변 부탁드립니다.

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

latest.skin.php 을 이미지도 보여줄 수 있는 내용으로 적용하셔야 합니다.


latest.skin.php 수정 내용

</font></p><p><font face="GulimChe"><?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php'); // 이부분 추가</font><font face="GulimChe">
</font></p><p><font face="GulimChe">$imgwidth = 100; //이미지 넓이
$imgheight = 80; //이미지 높이</font><font face="GulimChe">
</font></p><p><font face="GulimChe">~ 중간 생략 ~</font><font face="GulimChe">
</font></p><p><font face="GulimChe">// for 문 안에 아래 내용 추가</font></p><p><font face="GulimChe"><?php
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $imgwidth, $imgheight);
if($thumb['src']) {
     $thumb_img = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'" width="'.$imgwidth.'" height="'.$imgheight.'">';
     } </font></p><p><font face="GulimChe">echo $thumb_img;
?></font></p><p><font face="GulimChe">

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

이야기들
9년 전
이렇게 소스 추가 했는데요.

적용이 안되네요. 확인 한번 부탁드려요

<?php
if (!defined('_GNUBOARD_')) exit; //개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
global $is_admin;

$n_thumb_width = 114; //썸네일 가로 크기
$n_thumb_height = 114; //썸네일 세로 크기
?>

<link rel="stylesheet" href="<?php echo $latest_skin_url; ?>/style.css">

<table border="0" height="114" cellspacing="0" cellpadding="0">
<tr><td>

<section class="n_gallery_wrap">
<?php if (count($list) == 0) { //게시물이 없을 경우 ?>
<div class="n_no_list">게시물이 없습니다.</div>
<?php } else { //게시물이 있을 경우 ?>
<ul class="n_thumb">
<?php for ($i = 0; $i < count($list); $i++) { ?>
<li>
<a href="<?php echo $list[$i]['href']; ?>">
<?php
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $imgwidth, $imgheight);
if($thumb['src']) {
$thumb_img = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'" width="'.$imgwidth.'" height="'.$imgheight.'">';
}
echo $thumb_img;


$n_thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $n_thumb_width, $n_thumb_height);
$n_noimg = "$latest_skin_url/img/noimg.gif";
if($n_thumb['src']) {
$img_content = '<img src="'.$n_thumb['src'].'" width="'.$n_thumb_width.'" height="'.$n_thumb_height.'" alt="'.$list[$i]['subject'].'" title="" />';
} else {
$img_content = '<img src="'.$n_noimg.'" width="'.$n_thumb_width.'" height="'.$n_thumb_height.'" alt="이미지없음" title="" />';
}
echo $img_content;
?>
</a>

</li>
<?php } ?>
</ul>
<?php } ?>
</section>

</td></tr></table>
선우善友
9년 전
이미지 출력을 이중으로 중복해서 할 필요는 없습니다.
썸네일 크기를 $n_thumb_width 식으로 정의하셨으니까,
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $imgwidth, $imgheight); 이 부분을 삭제하시고 아래처럼 해보세요.
[code]
<a href="<?php echo $list[$i]['href']; ?>">
<?php
$n_thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $n_thumb_width, $n_thumb_height);
$n_noimg = "$latest_skin_url/img/noimg.gif";
if($n_thumb['src']) {
$img_content = '<img src="'.$n_thumb['src'].'" width="'.$n_thumb_width.'" height="'.$n_thumb_height.'" alt="'.$list[$i]['subject'].'" title="" />';
} else {
$img_content = '<img src="'.$n_noimg.'" width="'.$n_thumb_width.'" height="'.$n_thumb_height.'" alt="이미지없음" title="" />';
}
echo $img_content;
?>
</a>
[/code]

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인