묻고답하기

사용된 위젯의 원본은

http://www.xpressengine.com/index.php?&mid=download&search_keyword=%EB%9E%AD%ED%82%B9&package_srl=18324351

위 주소에서 받아서 사용하였습니다.

질문의 요지는 현재 위 위젯은 전체 모든 기간에서 다운로드 랭킹이 높은 목록을 출력하는데

이렇게 되면 상위에 있던 게시물이 계속 상위권에 머물르기 때문에 7일내로 목록을 출력하고자 합니다.

 

 

[기본소스]

rank_download.class

<?php
    /**
     * @class rank_download
     * @author Simulz.com (k10206@naver.com)
     * @brief 파일 다운로드 랭킹
     **/

    class rank_download extends WidgetHandler {

        /**
         * @brief 위젯의 실행 부분
         *
         * ./widgets/위젯/conf/info.xml 에 선언한 extra_vars를 args로 받는다
         * 결과를 만든후 print가 아니라 return 해주어야 한다
         **/
        function proc($args) {
            // 대상 모듈 (mid_list는 기존 위젯의 호환을 위해서 처리하는 루틴을 유지. module_srls로 위젯에서 변경)
            $oModuleModel = &getModel('module');
            if($args->mid_list) {
                $mid_list = explode(",",$args->mid_list);
                if(count($mid_list)) {
                    $module_srls = $oModuleModel->getModuleSrlByMid($mid_list);
                    if(count($module_srls)) $args->module_srls = implode(',',$module_srls);
                    else $args->module_srls = null;
                }
            }

            // 제목
            $title = $args->title;

            // 정렬 대상
            $order_target = $args->order_target;

            // 정렬 순서
            $order_type = $args->order_type;
            if(!in_array($order_type, array('asc','desc'))) $order_type = 'asc';

            // 출력된 목록 수
            $list_count = (int)$args->list_count;
            if(!$list_count) $list_count = 5;

            // 대상 모듈이 선택되어 있지 않으면 해당 사이트의 전체 모듈을 대상으로 함
            $site_module_info = Context::get('site_module_info');
            if($args->module_srls) $obj->module_srl = $args->module_srls;
            else if($site_module_info) $obj->site_srl = (int)$site_module_info->site_srl;

            // FileModel::getFileList()를 이용하기 위한 변수 정리
            $obj->direct_download = ($args->attach_type == "noimage") ? "N": (($args->attach_type == "image") ? "Y" : "");

            if($args->without_image == "true") $obj->direct_download = "N";
            $obj->list_count = $list_count;
            $obj->sort_index = $order_target;
            $obj->order_type = $args->order_type;

            // 다운로드 횟수 1이상만 검색
            $obj->download_count = 1;

            $output = executeQueryArray('widgets.rank_download.getFileList', $obj);

            // 오류가 생기면 그냥 무시
            if(!$output->toBool()) ;

            $oFileModel = &getModel('file');

            if(count($output->data)) {
                foreach($output->data as $key => $val) {
                    $file = $val;
                    $file->download_url = $oFileModel->getDownloadUrl("$val->file_srl, $val->sid);

                    $file->source_filename = htmlspecialchars($val->source_filename);
                    $file_list[$key] = $file;
                }
            }

            $widget_info->title = $title;
            $widget_info->list_count = $list_count;
            $widget_info->file_list = $file_list;
            $widget_info->download = $args->download == "Y" ? true : false;
            $widget_info->subject_cut_size = $subject_cut_size;

            Context::set('widget_info', $widget_info);

            // 템플릿의 스킨 경로를 지정 (skin, colorset에 따른 값을 설정)
            $tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
            Context::set('colorset', $args->colorset);

            // 템플릿 파일을 지정
            $tpl_file = 'list';

            // 템플릿 컴파일
            $oTemplate = &TemplateHandler::getInstance();
            $output = $oTemplate->compile($tpl_path, $tpl_file);
            return $output;
        }
    }
?>

위 중간에 부분에

   //추가 7일이내의 게시물만 검색
   $db_args->regdate = date("Ymd", mktime(0, 0, 0, date('m'), date('d')-7, date('Y')));
               $db_args->sort_index = 'readed_count';
            $db_args->order_type = 'desc';
            $output = executeQueryArray('widgets.rank_download.getFileList', $db_args);
            if($output->data) {
                foreach($output->data as $k => $v) {
                    $oDocument = null;
                    $oDocument = $oDocumentModel->getDocument();
                    $oDocument->setAttribute($v, false);
                    $GLOBALS['XE_DOCUMENT_LIST'][$oDocument->document_srl] = $oDocument;
                    $output->data[$k] = $oDocument;
                }
                $oDocumentModel->setToAllDocumentExtraVars();
            }
            $widget_info->popular_documents = $output->data;

            Context::set('widget_info', $widget_info);

를 추가하고

 

 

[기본소스]

getFileList.xml

<query id="getFileList" action="select">
    <tables>
        <table name="files" />
        <table name="modules" />
    </tables>
    <columns>
        <column name="files.*" />
    </columns>
    <conditions>

        <condition operation="equal" column="modules.site_srl" var="site_srl" />
        <condition operation="in" column="modules.module_srl" var="module_srl" pipe="and" />
        <condition operation="equal" column="files.module_srl" default="modules.module_srl" pipe="and" />
        <condition operation="equal" column="files.isvalid" default="Y" pipe="and" />
        <condition operation="more" column="files.download_count" var="download_count" pipe="and" />
        <condition operation="equal" column="files.direct_download" var="direct_download" pipe="and" />
    </conditions>
    <navigation>
        <index var="sort_index" default="files.download_count" order="desc" />
        <list_count var="list_count" default="20" />
    </navigation>
</query>

위 내용부분에도

  <condition operation="more" column="regdate" var="regdate" filter="number" pipe="and" />
 

내용을 추가했는데 다른 분들이 작성한 것을 짜집기해서 그런지 ㅠ_ㅠ 실제로 적용이 안되는데

rank_download.class

아무래도 이부분이 잘못된 것 같은데 php에 p도 모르는 무지한 사람입니다 죄송합니다.

어떻게 수정을 해야 할까요 조언좀 부탁드립니다 ㅠ_ㅠ
아울러 날씨 추운데 감기 조심하세요

 

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
94DT [HELP] 게시글 쓸때마다 script type ... 이상한 영어가 뜹니다 [3] 2011.12.23 by iceman237
키스미베이베 애드온 같은걸 이름바꿔서 두개중첩사용 가능한가요 [1] 2011.12.23 by 월하선향
러브수아 레이아웃에서 z-index 관련 질문입니다. [1] 2011.12.23 by XEMANIA
대전꺽다리 제로보드FTP설정오류 문의!  
djaos 포인트내역 볼수있게 못하나요? [1] 2011.12.23 by 월하선향
김소영487 content 위젯 생성시 오류가 발생합니다. [1] 2011.12.23 by XEMANIA
Chro 게시판에 표시되는 메뉴트리의 링크를 없앨수 있을까요? [1] file 2011.12.23 by 송동우
왕초보홈피만들기 게시판에 글쓰기 오류 메시지? [1] 2011.12.23 by 송동우
산책이 xe1.5.1 관리자 설정 오류 file  
▒푸른하늘▒ 일본 서버에 설치시 오류가 납니다. [1] 2011.12.23 by sol
그림자밖으로 게시판 문서번호  
jjin88 익명 기능 사용시 사용자 아이디 알아내는 방법? [1] 2011.12.23 by mena
선비826 사이트설정>레이아웃> 레이아웃 편집에서....레이아웃 파일 저장소  
최종명314 에러 확인 부탁드립니다. [2] 2011.12.23 by 최종명314
포니미 업데이트후 제어판이 몽땅 file  
abc920 애드온이 뭔가요!!!!!!!!!! 배너 링크 방명록!  
맹랑한하루 게시판 검색 대상 지정 관련..알려주세요. file  
마법의가을 특정게시판에 작성된글을 수정할수없게 하고싶습니다. [2] 2011.12.22 by 감로수
제로이드 페이지모듈에서 페이지보면 [1] 2011.12.22 by 송동우
Free942 본문에 첨부파일 있을 경우 플래시 플레이어 삽입 방법좀 문의드립니다.  
Free942 다운로드 랭킹 위젯에 전체기간을 7일내로 수정하고 싶습니다!  
제로이드 음악태그 소스좀 봐주세요~ [3] 2011.12.22 by 송동우
준수준성아빠 모바일 동영상 [1] 2011.12.22 by iceman237
goodxe XE레이아웃에 페이지만들어 동영상 삽입하면 하위메뉴가 동영상뒤에 숨어버려요 [1] file 2011.12.22 by 송동우
영석쓰 xe 오늘설치만 벌써 9번째...진짜.. 욕나오네요..ㅎㅎㅎ [1] 2011.12.22 by 송동우
초보모임 안녕하세요 ㅠㅠ 제가 너무 급하네요 ㅠ [1] 2011.12.22 by XEMANIA
이동식디스크 html5로 홈페이지를 꾸미고 제로보드 쓰고싶은데.. [1] 2011.12.22 by XEMANIA
산책이 xe 설치 후 추가 설치를 해야 하나요?  
breatheal 포워딩만하면 모바일뷰 해상도가 커집니다... ㅠㅠ [1] 2011.12.22 by breatheal
호연옴므 3단계 메뉴 질문드립니다.