Skip to content

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

Description

@churow

게시판 모듈의 댓글 스킨들을 보면
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">

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions