최신글에서 게시판 두개 나오게 하는 것 질문

최신글에서 게시판 두개 나오게 하는 것 질문

QA

최신글에서 게시판 두개 나오게 하는 것 질문

본문

<?php echo latest('theme/basic', "gaia01", 5, 25);        ?>

 

하나만 나오는거는 위와 같이 해서 나오는데요 

두개가 나오게 하려면 어떻게 해야해요?

왕초보라 힘드네요.

이 질문에 댓글 쓰기 :

답변 4

<?php echo latest('theme/basic', "gaia01,gaia02", 5, 25);        ?>

위와같이 하면 안되네요.

이거 theme/basic 경로의 index 파일 수정하는거는 맞죠?

 

 

최신글 기본 함수가 아니라 새로 함수를 추가해서 하는 겁니다.
본문 내용을 처음부터 살펴보세요. 팁에 있는 내용 그대로 적용해야 합니다.
latest_all 함수를 추가하고 해당 함수로 출력하는 겁니다.
latest_all("스킨명", "게시판명1,게시판명2,게시판명3,게시판명4", 출력갯수, 글자수);

latest.lib.php 파일맨 아래에 위의 길다란 소스를 전부 넣고 그 아래에 
echo latest_all("basic", "gaia01,gaia02", 3, 15); 
위와같은 형식으로 넣었는데 왜 안되죠? 
그니까 위에 본문 길다란거를 latest.lib.php 파일 맨 하단에 추가하고나서 
또 그 아래에 echo latest_all("basic", "gaia01,gaia02", 3, 15); 을 넣었습니다. 
하나의 게시판 gaia01 만 출력됩니다.ㅠㅠ

 

다시 말씀 드리면

기존 latest.lib.php 파일 아래에

위의 길다란 소스

+     echo latest_all("basic", "gaia01,gaia02", 3, 15);

하나의 게시판만 출력됨

 

1.덧붙인 소스에 추가할 것이 있는지 여부

2. 덧붙인 소스를 위의 길다란 장문 중간 어디에 넣어야 하는건지 여부

3.latest.lib.php 이곳에 추가로 덧붙이는거 맞는지 여부

위 3가지가 질문의 요지이구요.

만약 아니라면 어디에 위의 소스를 어느부분에 넣어야 하는지 부탁드립니다.

echo latest_all("basic", "gaia01,gaia02", 3, 15); 소스는 함수 아래 넣는 게 아니라,

출력하실 곳에 넣습니다. (예를 들어, 메인 경우, index.php 파일)

그리고,

php 소스니까, 앞에 아래처럼 넣어주셔야 해요.
<?php echo latest_all("basic", "gaia01,gaia02", 3, 15); ?>

theme/basic/index 파일을 아래와같이 하였고요.

<?php
define('_INDEX_', true);
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if (G5_IS_MOBILE) {
    include_once(G5_THEME_MOBILE_PATH.'/index.php');
    return;
}

include_once(G5_THEME_PATH.'/head.php');
?>

<h2 class="sound_only">최신글</h2>
<!-- 최신글 시작 { -->
<?php
//  최신글
$sql = " select bo_table
            from `{$g5['board_table']}` a left join `{$g5['group_table']}` b on (a.gr_id=b.gr_id)
            where a.bo_device <> 'mobile' ";
if(!$is_admin)
    $sql .= " and a.bo_use_cert = '' ";
$sql .= " order by b.gr_order, a.bo_order ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
    if ($i%2==1) $lt_style = "margin-left:20px";
    else $lt_style = "";
?>
    <div style="float:left;<?php echo $lt_style ?>">
        <?php
    
        // 이 함수가 바로 최신글을 추출하는 역할을 합니다.
        // 사용방법 : latest(스킨, 게시판아이디, 출력라인, 글자수);
        // 테마의 스킨을 사용하려면 theme/basic 과 같이 지정
        <?php echo latest_all("basic", "gaia01,gaia02", 3, 15); ?>

    </div>
<?php
}
?>
<!-- } 최신글 끝 -->

<?php
include_once(G5_THEME_PATH.'/tail.php');
?>

-------------------------------------------------------------------

lib/latest.lib 파일안에 길다란 글을 덧붙여서 아래와같이 하였는데 안됩니다.

아래는 덧붙인 latest.lib 입니다.

오늘 마지막 글입니다.

안되면 내일을 기다려야 함.ㅠㅠ

<?php
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
// $cache_time 캐시 갱신시간
function latest($skin_dir='', $bo_table, $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;
        }
    }

    $cache_fwrite = false;
    if(G5_USE_CACHE) {
        $cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";

        if(!file_exists($cache_file)) {
            $cache_fwrite = true;
        } else {
            if($cache_time > 0) {
                $filetime = filemtime($cache_file);
                if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) {
                    @unlink($cache_file);
                    $cache_fwrite = true;
                }
            }

            if(!$cache_fwrite)
                include($cache_file);
        }
    }

    if(!G5_USE_CACHE || $cache_fwrite) {
        $list = array();

        $sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
        $board = sql_fetch($sql);
        $bo_subject = get_text($board['bo_subject']);

        $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
        $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
        $result = sql_query($sql);
        for ($i=0; $row = sql_fetch_array($result); $i++) {
            $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
        }

        if($cache_fwrite) {
            $handle = fopen($cache_file, 'w');
            $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".$bo_subject."';\n\$list=".var_export($list, true)."?>";
            fwrite($handle, $cache_content);
            fclose($handle);
        }
    }

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

    return $content;
}
?>

<?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;
}
?>
 

자세히 가르처주시면 백골난망이겠습니다.

컴 교육이라고는 하나도 받지 못한 쉰세대라 힘이듭니다.

감사합니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 2,577
QA 내용 검색

회원로그인

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