xpressengine / xe-core

XpressEngine 1.x
https://xe1.xpressengine.com
Other
89 stars 62 forks source link

게시판 모듈 댓글 스킨의 반복문 실행 방식 문제 #2402

Open churow opened 5 years ago

churow commented 5 years ago

게시판 모듈의 댓글 스킨들을 보면 modules/board/skins/default/_comment.html modules/board/skins/xedition/_comment.html

아래와 같이 반복문을 실행하게 되어 있는데 <li loop="$oDocument->getComments()=>$key,$comment">

이것은 아래와 같이 컴파일이 되어, 결국 $oDocument->getComments()를 세 번씩 부르게 됩니다. <?php if($__Context->oDocument->getComments()&&count($__Context->oDocument->getComments()))foreach($__Context->oDocument->getComments() as $__Context->key=>$__Context->comment){ ?>

게다가 $oDocument->getComments()는 document.getComments라는 트리거를 부르는데, 이 트리거를 등록한 모듈에서는 의도하지 않게 세 번씩 같은 트리거를 부르게 됩니다.

아래와 같이 별도의 변수에 결과값을 받아 놓고, 그 변수를 이용해서 반복문을 실행하는 것이 낫겠습니다. {@ $comment_list = $oDocument->getComments(); } <li loop="$comment_list=>$key,$comment">