묻고답하기

사용된 위젯의 원본은

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 남기남
정원진284 초보ㅠㅠ) 레이아웃 상단 하단 여백이거 어캐 없애나요 ㅠㅠ?? [1] file 2011.12.21 by 웹 엔진
간지파파 외부페이지 From POST 된 값을 쿼리에 적용 시킬떼 [1] 2011.12.21 by 닉이얌
미루아 확장변수를 이용해서 본문에 이미지를 넣고 싶습니다. [1] 2011.12.21 by 송동우
아주라모 헤더 부분 플래시 넣기 알려주세요 ???  
San. 유저정보에서 일반유저는 닉네임 변경을 못하게하려고합니다. [1] 2011.12.22 by 송동우
王코털 1.5.1 업데이트 이후 댓글이 등록되지 않습니다. [1] 2011.12.22 by 王코털
공돌이2 도와주세요. [1] 2011.12.22 by 해피보이
환향 홈페이지를 못 만들고 있는데요.. [1] 2011.12.22 by 해피보이
아주라모 이메일로 설정했는데, 아이디를 물어보네요?  
샤이니라 생일 입력 받기  
간디작살 크롬에서 플래시 투명배경이 검은색으로 나타납니다. [1] file 2011.12.22 by 숭숭군
러브수아 게시판 리스트에 간략내용 추가를 할려면?  
데니스난강 혹시 xe에서 플래쉬는 어디까지올릴수가있나요?  
우리아기 시간 분 계산해서 그 시간대 별로 다른 이미지 보여주기  
생까는즐거움 사이트맵만을 백업 가능한가요?  
호연옴므 3단계 메뉴 질문드립니다.  
breatheal 포워딩만하면 모바일뷰 해상도가 커집니다... ㅠㅠ [1] 2011.12.22 by breatheal
산책이 xe 설치 후 추가 설치를 해야 하나요?  
이동식디스크 html5로 홈페이지를 꾸미고 제로보드 쓰고싶은데.. [1] 2011.12.22 by XEMANIA
초보모임 안녕하세요 ㅠㅠ 제가 너무 급하네요 ㅠ [1] 2011.12.22 by XEMANIA
영석쓰 xe 오늘설치만 벌써 9번째...진짜.. 욕나오네요..ㅎㅎㅎ [1] 2011.12.22 by 송동우
goodxe XE레이아웃에 페이지만들어 동영상 삽입하면 하위메뉴가 동영상뒤에 숨어버려요 [1] file 2011.12.22 by 송동우
준수준성아빠 모바일 동영상 [1] 2011.12.22 by iceman237
제로이드 음악태그 소스좀 봐주세요~ [3] 2011.12.22 by 송동우
Free942 다운로드 랭킹 위젯에 전체기간을 7일내로 수정하고 싶습니다!  
Free942 본문에 첨부파일 있을 경우 플래시 플레이어 삽입 방법좀 문의드립니다.  
제로이드 페이지모듈에서 페이지보면 [1] 2011.12.22 by 송동우
마법의가을 특정게시판에 작성된글을 수정할수없게 하고싶습니다. [2] 2011.12.22 by 감로수
맹랑한하루 게시판 검색 대상 지정 관련..알려주세요. file  
abc920 애드온이 뭔가요!!!!!!!!!! 배너 링크 방명록!