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

최신글 정렬방식, 각각 적용하기

나는낙타 7년 전 조회 3,607

먼저 홈페이지는 http://ndtl.skku.edu 입니다.

업체제작을 했는데, 받고나서부터 업체 대응이 제대로 되지 않아

아는 것도 거의 없는데 소스 하나하나보면서 직접 해결중이네요..

 

먼저, 최신글 3개 중에, 갤러리는 빼고

Recent publications 이랑 notice 만 각각 정렬이 필요합니다.

왜냐하면 Recent publications 연동되는 게시판에 날짜가 일반적인 wr_datetime가 아니고, 날짜 선택형이라서 wr_5로 따로 정의되어 있습니다. 

 

근데 업체에서 같은 latest.skin.php 파일에 연결해놔가지고, 처음에 날짜 출력 문제가 있었습니다.

날짜출력을 wr_5만 해놔서 notice에는 wr_5가 없었죠. 

 

그래서 basic1/latest.skin.php를 만들고 wr_datetime 로 해서 날짜출력은 해결했는데..

 

이것들을 정렬시키려고 보니, 이번엔 latest.lib.php 파일 하나에 전부 묶여있네요...

소스를 봐도 order 바꾸는 곳이 딱 한군데 있고, 그거 바꾸면 최근 게시물 3개다 정렬방식이 바뀝니다.

Recent publications는 wr_5로 정렬해야하고, Notice는 wr_datetime 으로 정렬해야하는데..

어떻게 해야 각각 적용시킬 수 있을까요..

 

latest.lib.php

 

// 최신글 추출 // $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 = "";             fwrite($handle, $cache_content);             fclose($handle);         }     //}     

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

    return $content; } ?>  

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

답변 2개

7년 전

wr_datetime으로 정렬한다는 것은 그누 기본 상태로 출력하면 될 것입니다

먼저 index..php에서 latest 출력 변경 ---> Recent publications 만

 

latest.lib.php는 원본에서 아래부분만 변경

 $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";

-->

if($options) $order = $options; else $order ='wr_num';

 $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by $order limit 0, {$rows} ";

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

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

7년 전

함수를 다른 이름으로 새로 만들어서 설정하는 방법이 있습니다.

예를 들어 이런식으로..

http://gnustudy.com/bbs/board.php?bo_table=skin_latest&wr_id=23

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

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

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

로그인