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

메인화면 최신글 분류 추출 문의 채택완료

최태풍 7년 전 조회 2,718

분류변로 메인화면에 추출 하고싶은데요

<?php
  echo latest_cate("basic", "test", 5, 10,"", "", "분류1");
?>
이렇게 하고
latest.lib.php  파일을 아래 와 같이 파란색을 코드처럼 바꾸었는데요..
원하는 분류데로 안나오고 그냥 전체 가 다 보여집니다.
어디 잘못된데가 있는지요?

</strong>

 </p>

<p><?php

if (!defined('_GNUBOARD_')) exit;</p>

<p>// 최신글 추출

// $cache_time 캐시 갱신시간</p>

<p><span style="color:#3498db">function latest_cate($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='',$category="") </span>

{

    global $g5;</p>

<p>    if (!$skin_dir) $skin_dir = 'basic';</p>

<p>    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;

        }

    }</p>

<p>    $cache_fwrite = false;

    if(G5_USE_CACHE) {

        $cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";</p>

<p>        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;

                }

            }</p>

<p>            if(!$cache_fwrite)

                include($cache_file);

        }

    }</p>

<p>    if(!G5_USE_CACHE || $cache_fwrite) {

        $list = array();</p>

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

        $board = sql_fetch($sql);

        $bo_subject = get_text($board['bo_subject']);</p>

<p>        $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름

<span style="color:#2980b9">        $sql = " select * from {$tmp_write_table} where ca_name='{$ca_name}' AND wr_is_comment = 0 order by wr_num limit 0, {$rows} "; </span></p>

<p>

        $result = sql_query($sql);

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

            $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);

        }</p>

<p>        if($cache_fwrite) {

            $handle = fopen($cache_file, 'w');

            $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".sql_escape_string($bo_subject)."';\n\$list=".var_export($list, true)."?>";

            fwrite($handle, $cache_content);

            fclose($handle);

        }

    }</p>

<p>    ob_start();

    include $latest_skin_path.'/latest.skin.php';

    $content = ob_get_contents();

    ob_end_clean();</p>

<p>    return $content;

}

?></p>

<p>

<strong>

 

 

라테스트 스킨(latest.skin.php)은 이걸 쓰고 있습니다.

</p>

<p> </p>

<p><div class="wrapper">

<h1 ><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>"><?php echo $bo_subject; ?> ▶</a></h1>

    <!-- CONTENT BEGIN -->

    <div id="content" class="block_portfolio_4c">

        <div class="inner"></p>

<p>            <div class="block_four_columns">

                <ul class="block_filtered_items">

                    <!-- portfolio item -->

                    <?php

                        for ($i=0; $i<count($list); $i++) {  

                        /* 원본 이미지를 뽑아보자  - JooSung - 20150528 추가 */

                        $list[$i][file] =get_file($bo_table, $list[$i][wr_id]);

                        $file = $list[$i][file][0][path].'/'. $list[$i][file][0][file];

                        /* 원본 이미지를 뽑아보자  - JooSung - 20150528 추가 */

                        $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $thumb_width, $thumb_height);

                        if($thumb['src']) {

                        $img = '<img src="'.$thumb['src'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" title="'.$list[$i][subject].'" />';

                        } else {

                        $img = '<img src="'.$latest_skin_url.'/img/noimage.png" width="'.$thumb_width.'" height="'.$thumb_height.'" title="이미지 없음" />';

                        }</p>

<p>                        $content = cut_str(strip_tags($list[$i][wr_content]), 76);

                    ?>        

                                        

                    <li class="column_3 filtering_item <?php echo $list[$i][wr_link1]?"video":""?>" title="<?php echo $list[$i][ca_name]?>">

                        <div class="pic_wrapper">

                            <span class="block_general_pic">

                                <? if ($list[$i][wr_link1]) { ?>

                                <a href="<?php echo $list[$i][wr_link1]?>"  title="<?php echo $list[$i][subject]?>" class="hover_1">

                                <? } else { ?>

                                <a href="<?php echo $list[$i][href]?>"  title="<?php echo $list[$i][subject]?>" class="hover_1">

                                <? } ?>

                                    <img width="<?php echo $thumb_width?>" height="<?php echo $thumb_height?>" src="<?php echo $thumb['src']?>" class="r_conner_pic wp-post-image" title="<?php echo $list[$i][subject]?>" />

                                    <span class="block_hover"> </span>

                                </a>                            

                            </span>

                        </div>

                        <p style="padding:5px;"><strong><a href="<?php echo $list[$i][href]?>"><?php echo $list[$i][subject]?> </a></strong>

                    </li></p>

<p>                    <? } ?>

                <!-- portfolio item -->                         

                </ul>

            </div>            

            

        </div>

    </div>

    <!-- CONTENT END --></p>

<p> </p>

<p>

 

 

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

답변 1개

채택된 답변
+20 포인트
e
7년 전

아래 해당 팁과 스킨을 참조하셔서 수정 또는 교체 하시면 될 듯합니다.

최신글 스킨은 기존것을 아무거나 쓰셔도 될테구요, 중요한건 latest.lib.php 파일의 코드입니다.

 

https://sir.kr/g5_tip/4129" target="_blank">https://sir.kr/g5_tip/4129  <-- 이거 하나만 적용하셔도 잘 동작 할 겁니다.

 

https://sir.kr/g5_skin/2928" target="_blank">https://sir.kr/g5_skin/2928

https://sir.kr/g5_skin/17903" target="_blank">https://sir.kr/g5_skin/17903

 

 

 

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

답변에 대한 댓글 1개

최태풍
7년 전
감사합니다..
분류에 있는부분은 잘 추출됩니다.
그런데 혹시 제가 2차 분류를 여분필드 5번에 넣었는데요.
이럴경우는 5번 필드에 있는건 추출이 어려울까요?

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

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

로그인