티스토리 뷰
xe 위젯 개념은 살펴봤으니 실제 xe 코어 다운로드 받으면 기본적으로 들어 있는 xe 카운터 위젯을 뜯어보겠다.
xe 코어 다운시 들어 있는 위젯중에 가장 심플한거라 선택해봤다.
먼저 info.xml 이 있으나 정보 부분이라 넘어가고.. 단 info.xml 에는 아래와 같은 description이 있다.
<description xml:lang="ko">
기본 카운터를 이용하여 전체, 어제, 오늘의 접속현황을 표시합니다.
counter 모듈이 설치되어 있어야 하고 counter 애드온이 켜져 있어야 합니다.
</description>
counter_status.class.php 를 열어보면
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class counter_status
* @author NAVER (developers@xpressengine.com)
* @version 0.1
* @brief Display counter status by using data in the counter module
*/
class counter_status extends WidgetHandler
{
/**
* @brief Widget execution
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
* After generating the result, do not print but return it.
*/
function proc($args)
{
// Get status of the accumulated, yesterday's, today's counts
$oCounterModel = getModel('counter');
$site_module_info = Context::get('site_module_info');
$output = $oCounterModel->getStatus(array('00000000', date('Ymd', $_SERVER['REQUEST_TIME']-60*60*24), date('Ymd')), $site_module_info->site_srl);
if(count($output))
{
foreach($output as $key => $val)
{
if(!$key) Context::set('total_counter', $val);
elseif($key == date("Ymd")) Context::set('today_counter', $val);
else Context::set('yesterday_counter', $val);
}
}
// Set a path of the template skin (values of skin, colorset settings)
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
Context::set('colorset', $args->colorset);
// Specify a template file
$tpl_file = 'counter_status';
// Compile a template
$oTemplate = &TemplateHandler::getInstance();
return $oTemplate->compile($tpl_path, $tpl_file);
}
}
/* End of file counter_status.class.php */
/* Location: ./widgets/counter_status/counter_status.class.php */
이렇게 위젯을 만들고 결과를 보면 아래와 같다.
'XE(XpressEngine) 강좌 > XE 위젯 제작 강좌' 카테고리의 다른 글
xe 위젯 개발 강좌 (5) - 위젯 확장변수를 이용한 bxslider xe 위젯 만들기 (0) | 2017.05.19 |
---|---|
xe 위젯 개발 강좌 (5) - counter 위젯을 사용하여 스킨 컬러셋 추가,사용하기 (0) | 2017.05.17 |
xe 위젯 개발 강좌 (4) - bxslider 를 이용한 위젯만들기 (0) | 2017.05.16 |
xe 위젯 개발 강좌 (3) - bxslider 를 이용한 위젯만들기 준비 (0) | 2017.05.16 |
xe 위젯 개발 강좌 (1) - 위젯 동작 원리 개념 (0) | 2017.05.16 |
- Total
- Today
- Yesterday
- esql
- 라이믹스 모듈
- 파이썬
- xe애드온
- 파싱
- 오라클
- 인포믹스
- EC
- Python
- C
- 자바
- 스크래핑
- 프로씨
- KG
- ocjap
- xe addon
- webix
- php
- proc
- 자바 smtp
- JDBC
- XE
- XE3
- 플러터
- 문자열
- 이클립스
- MySQL
- C언어
- ocajp
- 포인터
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |