게시판스킨 리스트아래 댓글출력 조절
CMS/프레임워크 | Rhymix 2.0 |
---|---|
개발 언어 | PHP 7.4 |
문제 페이지 주소 | 비공개 (작성 후 5일 경과) |
리스트 글제목 아래에 댓글을 함께 출력하는기능을 SketchBook5 게시판스킨에 적용을 해 보았습니다.
[Sample] https://moonhouse.co.kr/qa
<!-- 코멘트 리스트 시작 -->
{@$i = 0}
<tr class="r" loop="$document->getComments() => $key,$val" cond="$i < 2">
{@$i++}
<td class="replyContent" >
<div <!--@if($val->depth < 11)-->style="margin-left:{($val->depth)*1.3}em"<!--@else-->style="margin-left:13em"<!--@end--> class="replyIndent">
<div <!--@if($mi->div_column == 'yescolumn')-->style="width:100%"<!--@end--> style="text-align:left">
<a href="{getUrl('document_srl',$document->document_srl, 'comment_srl', $val->comment_srl)}#comment_{$val->comment_srl}" title="">
{cut_str(strip_tags($val->content),60,'...')}
</a>
</div>
</div>
</td>
<td class="author">{($val->nick_name)}</td>
<td class="date">{zdate($val->regdate, 'm.d/H.i')}</td>
</tr>
<!--@end-->
<!-- 코멘트 리스트 끝 -->
빨간색코드로 댓글의 수를 조절할 수 는 있겠는데
댓글영역의 상단에 최근댓글순으로 올릴 수는 없을까요?
아님 댓글 영역을 높이조절을 하여 스크롤로 보이게 할 수는 없을까요?
<tr>영역을 아무리 감싸도 높이 조절이 안되네요.
적용된 SketchBook5 게시판스킨 - 아직 갯수조절 코드는 삽입되어져 있지 않습니다.
https://moonhouse.co.kr/xemy/530374

댓글 11
$document->getComments()
이것도 배열일테니
이걸 다른 변수에 담아서 그 변수의 배열을 뒤집으면 되지 않을까요?
{@$i = 0}
{@$comments_list = $document->getComments();}
{@$comments_list = array_reverse($comments_list );}
<tr class="r" loop="$comments_list => $key,$val" cond="$i < 2">
잘 작동하네요.
역시 고수님들에게 물어 봐야되...
감사합니다.
{@$i = 0}
<tr class="r" loop="array_reverse($document->getComments()) => $key,$val" cond="$i < 2">
이런식으로도 충분히 가능합니다.
신문법이 작동이 안된다면 <!--@foreach()--> 문으로 바꿔주시면 되고요.
그렇다면 페이지수를 계산해서 마지막 페이지의 것을 가져오게 해야할꺼에요.
근데 혹시 댓글 영역을 높이조절을 하여 스크롤로 보이게 할 수는 없을까요? 를 구현하는 방법은 없을가요?
아님 토글적용 하는 방법이나...
너무 무리한 요구이면 죄송합니다.
tr td안에 코멘트들만 모아서 div로 감싸고 해당 div의 높이를 제한, overflow를 주면 되는데
지금은 게시물제목이나 각각의 코멘트나 모두 각각 tr이네요.
추후 사이트가 성장하였을때 해당 기능이 제거되어야할 수 있으니 해당 기능에 큰 미련을 가지지 않는 것이 좋을 것 같고요..
그리고 getComments 를 뒤집는 것보다 새롭게 디비에서 최신순으로 가져올 수 있도록 쿼리를 하는 것이 좀 더 나은 선택입니다.
전 코어를 수정하지 않고 그걸 만들만한 능력은 없어서요 -0-;;;;;
commentModel 클래스 안에 getNewestCommentList 함수를 사용하면 아래 쿼리를 이용합니다.
<query id="getNewestCommentList" action="select">
<tables>
<table name="comments" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="status" var="status" pipe="and" />
<condition operation="equal" column="is_secret" var="is_secret" pipe="and" />
<condition operation="in" column="module_srl" var="module_srl" filter="number" pipe="and" />
<condition operation="equal" column="document_srl" var="document_srl" filter="number" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="list_order" order="asc" />
<list_count var="list_count" default="20" />
</navigation>
</query>
굳이 코어를 수정하지 않고 module_srl이랑 같이 잘 넘기시면 됩니다.
$args = new stdClass();
$args->list_count = 5;
$args->module_srl = $module_srl
//문서번호는 상황에 맞게 코드 알아서 적절히
$args->document_srl = $document_srl;
$comment_list = getModel('comment')->getNewestCommentList($args);
관련 소스코드를 보기는 했는데 getCommentList만 보고 정렬순서는 고정이군!
하고 역순으로 동작하게 코어를 수정할수는 없으니 그건 포기하자!
라고 생각했는데... 이미 만들어져 있군요.ㅋ