티스토리 뷰

<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;

}





댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함