티스토리 뷰

예외 처리 코드 추가

애드온이 게시글 수정할 때 동작 되어 글 수정에 문제가 있습니다.


수정시에도

010-1234-****

이런식으로 나옴. 수정시에는 010-1234-5678 다나와야 하고 view 일때만 * 처리 되야함.


게시글이 노출될 때만 애드온이 동작하도록 수정합니다.



if($called_position == 'after_module_proc' && $this->module=="board") //board 모듈에서만 동작 하도록 함

{

$cur_act = Context::get('act');

if($cur_act != "" && $cur_act != "dispBoardContent") //act 확인

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;

$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']);

}


애드온이 동작할 상황들을 고려해서 코드를 추가합니다.


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함