| 라이믹스/XE | 라이믹스, XE |
|---|
0. 문서 아카이브 리스트를 만듭니다. 연도별, 월별, 일별로 몇 개의 문서가 있는지 count도 됩니다. 라이믹스에서 테스트했습니다.
1. 준비물:
- /modules/document/queries 폴더의
- getYearlyArchivedList.xml
- getMonthlyArchivedList.xml
- getDailyArchivedList.xml
- /modules/document/queries 폴더의
- document.model.php
- /modules/board 폴더의
- board.class.php
2. 단, getYearlyArchivedList.xml은 없으므로 다음과 같은 소스로 새로 만들어줘야 합니다.
<query id="getYearlyArchivedList" action="select">
<tables>
<table name="documents" />
</tables>
<columns>
<column name="substr(regdate,1,4)" alias="year" />
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="in" column="module_srl" var="module_srl" filter="number" />
<condition operation="like_prefix" column="regdate" var="regdate" pipe="and" />
</conditions>
<groups>
<group column="substr(regdate,1,4)" />
</groups>
</query>
3. getDailyArchivedList.xml도 형식에 알맞게 수정해주면 좋습니다.
- 1행의 <query id="getMonthlyArchivedList" action="select">을 다음과 같이 수정
<query id="getDailyArchivedList" action="select">
- 6행의 <column name="substr(regdate,1,8)" alias="month" />을 다음과 같이 수정
<column name="substr(regdate,1,8)" alias="day" />
4. documet.model.php의 847행쯤(getDailyArchivedList 함수 다음 부분)에 다음을 삽입합니다.
/**
* Bringing a year on the status of the yaerly posts
* @param object $obj
* @return object
*/
function getYearlyArchivedList($obj)
{
if($obj->mid)
{
$oModuleModel = getModel('module');
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($obj->mid);
}
// Module_srl passed the array may be a check whether the array
$args = new stdClass;
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
else $args->module_srl = $obj->module_srl;
$args->regdate = $obj->regdate;
$output = executeQuery('document.getYearlyArchivedList', $args);
if(!$output->toBool()) return $output;
if(!is_array($output->data)) $output->data = array($output->data);
return $output;
}
5. board.class.php의 12행을 다음으로 교체합니다.
var $search_option = array('title_content','title','content','comment','user_name','nick_name','user_id','tag','regdate');
즉, array에 regdate를 추가해준 것이죠.
6. 이로써 모든 사전 준비가 끝났습니다.
7. 레이아웃 스킨이나 게시판 스킨 등의 적절한 위치에 다음의 소스를 삽입하고, 각자 취향에 따라 css나 js를 활용해서 스타일링하시면 됩니다.
{@
$args = new stdClass;
$args->module_srl = $module_info->module_srl;
$oDocumentModel = &getModel('document');
$year = $oDocumentModel->getYearlyArchivedList($args);
$month = $oDocumentModel->getMonthlyArchivedList($args);
$day = $oDocumentModel->getDailyArchivedList($args);
}
<div loop="array_reverse($year->data)=>$key1,$val1" class="archive-yearly">
<a href="{getUrl('','mid',$mid,'search_target','regdate','search_keyword',$val1->year)}">
{zdate($val1->year,'Y')}({number_format($val1->count)})
</a>
<div loop="array_reverse($month->data)=>$key2,$val2" cond="zdate($val2->month,'Y')==zdate($val1->year,'Y')" class="archive-monthly">
<a href="{getUrl('','mid',$mid,'search_target','regdate','search_keyword',$val2->month)}">
{zdate($val2->month,'F')}({number_format($val2->count)})
</a>
<div loop="array_reverse($day->data)=>$key3,$val3" cond="zdate($val3->day,'Ym')==zdate($val2->month,'Ym')" class="archive-daily">
<a href="{getUrl('','mid',$mid,'search_target','regdate','search_keyword',$val3->day)}">
{zdate($val3->day,'jS')}({number_format($val3->count)})
</a>
</div>
</div>
</div>
- $args->module_srl 정의 부분에서 $module_info->module_srl은 현재 로딩된 모듈의 srl을 가져오는 것이므로, 다른 모듈을 불러오거나 포함하고 싶을 땐 본인 취향에 맞춰 응용하면 됩니다. 예: '143, 145' 로 하면 143번과 145번 모듈에서 문서를 가져 옵니다.
- 이상입니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 9 | 후원회원 가입 받을 때 서명(싸인, 사인) 받는 법 [1] | 아포리아 | 2015.03.25 | 589 |
| 8 | 후원회원 가입 받을 때 서명(싸인, 사인) 받는 법 2 - 복수의 패드 및 해당 확장변수가 필수/선택일 경우를 모두 고려함 | 아포리아 | 2016.01.25 | 321 |
| 7 |
후원회원 가입 받을 때 후원금액 선택 받는 법
| 아포리아 | 2016.08.27 | 463 |
| 6 |
코어 수정 없이, 시조 댓글의 리스트만 출력하고, 자손 댓글의 리스트는 로드하지 않았다가 클릭 이벤트로 ajax 호출하기
| 아포리아 | 2017.04.18 | 2104 |
| 5 | 스킨에서 댓글 cpage 자동 감지 | 아포리아 | 2017.05.06 | 702 |
| 4 |
게시판 본문의 분류를 출력할 때 상위 카테고리도 같이 출력하기
[1] | 아포리아 | 2017.05.08 | 417 |
| 3 | 스크립트파일(js)을 하단부에서 불러오게 하기 | 아포리아 | 2016.08.30 | 249 |
| » | 년월일별 아카이브 리스트 만들기 | 아포리아 | 2016.08.30 | 409 |
| 1 | 게시판 "본문"에서 확장변수(단일/다중선택) 기본값의 다국어 출력 방법 [1] | 아포리아 | 2016.08.30 | 489 |