티스토리 뷰
<extra_vars>
<var name="extra_vars1">
<title xml:lang="ko">애드온 추가설정 값 1</title>
<title xml:lang="en">extra value for addon 1</title>
<description xml:lang="ko">추가 설정값의 설명을 작성합니다. 1</description>
<description xml:lang="en">description for extra value 1</description>
</var>
<var name="extra_vars2" type="textarea">
<title xml:lang="ko">애드온 추가설정 값 2</title>
<title xml:lang="en">extra value for addon 2</title>
<description xml:lang="ko">추가 설정값의 설명을 작성합니다. 2</description>
<description xml:lang="en">description for extra value 2</description>
</var>
<var name="extra_vars3" type="select">
<options value="0">
<title xml:lang="ko">옵션 1</title>
<title xml:lang="en">option 1</title>
</options>
<options value="1">
<title xml:lang="ko">옵션2</title>
<title xml:lang="en">option 2</title>
</options>
<title xml:lang="ko">애드온 추가설정 값 3</title>
<title xml:lang="en">option 2</title>
<description xml:lang="ko">추가 설정값의 설명을 작성합니다. 3</description>
<description xml:lang="en">description for extra value 3</description>
</var>
</extra_vars>
이렇게 info.xml에 추가를 하면 된다.
<addon version="0.2">
여기에추가
</addon>
<addon> 엘리먼트 안에 추가하면 된다.
그리고 나서 애드온명.addon.php 파일에서 $addon_info 로 접근할 수 있다.
예를들어 아래와 같이 접근할 수 있다.
$vars1 = $addon_info->extra_vars1;
$vars2 = $addon_info->extra_vars2;
$vars3 = $addon_info->extra_vars3;
확장변수를 추가해서 문자열을 본문내용 앞뒤로 붙이는 테스트용 애드온을 만들어 봤다.
최종 애드온 소스는
<?php
if(!defined('__XE__'))
exit();
if($called_position == 'after_module_proc' && $this->module=="board")
{
$cur_act = Context::get('act');
if($cur_act != "" && $cur_act != "dispBoardContent")
return;
$document_srl = Context::get('document_srl');
if(!$document_srl)
return;
$oDocument = Context::get('oDocument');
if(!$oDocument)
return;
if($oDocument->document_srl != $document_srl)
return;
$vars1 = $addon_info->extra_vars1;
$vars2 = $addon_info->extra_vars2;
$vars3 = $addon_info->extra_vars3;
if($vars3==1){
$var3_text="<p>1을 선택하셨습니다.</p>";
}else if($vars3==2){
$var3_text="<p>2를 선택하셨습니다.</p>";
}
$pattern = "/(0[0-9]{1,2})-([0-9]{3,4})-([0-9]{4})/i";
$replace = "$1-$2-****";
$oDocument->variables['content'] = preg_replace($pattern, $replace, $oDocument->variables['content']);
$oDocument->variables['content'] = $vars1.$oDocument->variables['content'].$vars2.$var3_text;
}
'XE(XpressEngine) 강좌 > 애드온 강좌' 카테고리의 다른 글
xe 애드온 (xe addon) 강좌 (5) - 디버깅 (0) | 2017.04.27 |
---|---|
xe 애드온 (xe addon) 강좌 (4) (0) | 2017.04.27 |
xe 애드온 (xe addon) 강좌 (3) (0) | 2017.04.27 |
xe 애드온 (xe addon) 강좌 (2) (0) | 2017.04.26 |
xe 애드온 (xe addon) 강좌 (1) (0) | 2017.04.26 |
- Total
- Today
- Yesterday
- 자바
- XE3
- KG
- 이클립스
- 오라클
- 포인터
- JDBC
- xe addon
- 파싱
- proc
- 플러터
- MySQL
- ocajp
- xe애드온
- XE
- C언어
- EC
- webix
- 파이썬
- esql
- 프로씨
- 스크래핑
- php
- C
- 인포믹스
- Python
- 자바 smtp
- 라이믹스 모듈
- 문자열
- ocjap
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |