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

다중 최신갤러리 특정 카테고리 출력 관련 도움 부탁드립니다. 채택완료

opman 2년 전 조회 1,247

그누위즈님 latest_all 참고해서 https://sir.kr/g5_tip/4103,

다중 최신갤러리 작업중인데 각각의 게시글 특정 카테고리만 출력하고 싶은데

잘 안되네요. 도움 부탁드립니다.

 

갤러리a, 갤러리b, 갤러리c 의 특정 카테고리 출력

<?php echo latest_all('갤러리a|당근, "갤러리b|참외,갤러리c|수박",5, 25); ?>

 

 

아래 latest.lib.php  내용입니다.

 

</strong></p>

<p>function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='')

 {</p>

<p>    global $g5;

    

   // 카테고리 추출

   /* list($bo_table, $category) = explode("|", $bo_table);

    if($category) {

        $categories = explode(",", $category);

        $where = " AND ca_name IN('".implode("', '", $categories)."')";

    } */</p>

<p> </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>        $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}";</p>

<p>        $result = sql_query($sql);

        

        for ($i=0; $row=sql_fetch_array($result); $i++) {</p>

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

  

            $board = sql_fetch($sql);</p>

<p>            $tmp_write_table = $g5['write_prefix'] . $row['bo_table'];

            $row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");</p>

<p>            $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'];

        }</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>
 

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

답변 1개

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

$g5['board_new_table'] 테이블에는 카테고리를 저장하지 않아서..

각 게시판 테이블과 join 을 해서 해당 게시판의 카테고리 where 조건을 추가해서

for 문을 돌려서.. 각 게시물을 가져와서 배열에 저장한 후에..

다시 원하는 순서대로.. 배열을 정렬 해야하겠네요..

 

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

답변에 대한 댓글 1개

o
opman
2년 전
감사합니다. 적용해 보겠습니다.

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

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

로그인