XpressEngine과 관련된 팁이나 강좌를 소개하는 게시판입니다.
자신이 생각하기에는 아주 사소한 내용이라도 누군가에게는 큰 도움이 될 수 있습니다.
XE 원 소스 코드를 수정하는 팁은 당장은 도움이 될지 몰라도 결국 XE 업그레이드를 하지 못하게 되니 팁을 올리시는 분이나 팁을 적용하시는 분이나 모두 주의 부탁드립니다.

최근 댓글이 가장 위로 정렬

조회 수 4007 추천 수 1 2007.12.20 01:04:34
질문 & 답변에 질문했었는데 답변이 없으셔서
혼자 끙끙하다가 겨우 해결했습니다

최근 댓글이 가장 위로 정렬되도록 하는 소스입니다
참고하시고 더 좋은 방향으로 발전될 수 있도록 사용하시기를...

modules/comment/comment.model.php Line 173 부터 비교해 가면서 수정하세요~~

//modules/comment/comment.model.php 에서 173 line부터 다음으로 수정
//(여기서 // 역순 정렬을 위해 삽입/수정된 부분만 비교해서 바꾸시면 됩니다)

$root = NULL;
$list = NULL;
$root_temp = NULL;           // 역순 정렬을 위해 삽입 (softmind)

// 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음
$logged_info = Context::get('logged_info');

$root_count = 0;
// loop를 돌면서 코멘트의 계층 구조 만듬 
for($i=$comment_count-1;$i>=0;$i--) {

 $comment_srl = $source_list[$i]->comment_srl;
 $parent_srl = $source_list[$i]->parent_srl;
 $member_srl = $source_list[$i]->member_srl;

 // OL/LI 태그를 위한 치환 처리
 $source_list[$i]->content = preg_replace('!<(ol|ul|blockquote)>!is','<\\1 style="margin-left:40px;">',$source_list[$i]->content);

 // url에 대해서 정규표현식으로 치환
 $source_list[$i]->content = preg_replace('!([^>^"^\'^=])(http|https|ftp|mms):\/\/([^ ^<^"^\']*)!is','$1<a href="$2://$3" onclick="window.open(this.href);return false;">$2://$3</a>',' '.$source_list[$i]->content);

 if(!$comment_srl) continue;

 //if($is_admin || $this->isGranted($comment_srl) || $member_srl == $logged_info->member_srl) $source_list[$i]->is_granted = true;

 // 목록을 만듬
 $list[$comment_srl] = $source_list[$i];

 if($parent_srl) {
  $list[$parent_srl]->child[] = &$list[$comment_srl];
 } else {
  $root_temp->child[] = &$list[$comment_srl];   // 역순 정렬을 위해 수정 (softmind)
  $root_count++;          // 역순 정렬을 위해 삽입 (softmind)
 }
}
for($j=0;$j<=$root_count;$j++){        // 역순 정렬을 위해 삽입 (softmind) 
 $root->child[$j] = $root_temp->child[$root_count-$j-1]; // 역순 정렬을 위해 삽입 (softmind)
}               // 역순 정렬을 위해 삽입 (softmind)
$this->_arrangeComment($comment_list, $root->child, 0);
return $comment_list;

잘 사용 하시기를..

혹시 가능하시면 게시판 스킨에서 설정 가능하도록 누가 만들어 주시면 감사할듯~~


본 소스는 베타 버젼에 적용 가능합니다.

댓글 '2'

[레벨:3]레드맨

2008.01.10 03:08:39
*.112.125.125

먼저 좋은 팁 알려주신 쏘프티님께 감사드려요~ ^^

소스에 약간의 오류가 있어서 알려드립니다.


//modules/comment/comment.model.php 에서 173 line부터 다음으로 수정    
//(여기서 // 역순 정렬을 위해 삽입/수정된 부분만 비교해서 바꾸시면 됩니다)    
   
$root = NULL;    
$list = NULL;    
$root_temp = NULL;           // 역순 정렬을 위해 삽입 (softmind)    
   
// 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음    
$logged_info = Context::get('logged_info');    
   
$root_count = 0;   
---------------------------->요놈도 추가해줘야 합니다. 꼭!!! 

// loop를 돌면서 코멘트의 계층 구조 만듬     
for($i=$comment_count-1;$i>=0;$i--) {    
   
 $comment_srl = $source_list[$i]->comment_srl;    
 $parent_srl = $source_list[$i]->parent_srl;    
 $member_srl = $source_list[$i]->member_srl;    
   
 // OL/LI 태그를 위한 치환 처리    
 $source_list[$i]->content = preg_replace('!<(ol|ul|blockquote)>!is','<\\1 style="margin-left:40px;">',$source_list[$i]->content);    
   
 // url에 대해서 정규표현식으로 치환    
 $source_list[$i]->content = preg_replace('!([^>^"^\'^=])(http|https|ftp|mms):\/\/([^ ^<^"^\']*)!is','$1<a href="$2://$3" onclick="window.open(this.href);return false;">$2://$3</a>',' '.$source_list[$i]->content);    
   
 if(!$comment_srl) continue;    
   
 //if($is_admin || $this->isGranted($comment_srl) || $member_srl == $logged_info->member_srl) $source_list[$i]->is_granted = true;    
   
 // 목록을 만듬    
 $list[$comment_srl] = $source_list[$i];    
   
 if($parent_srl) {    
  $list[$parent_srl]->child[] = &$list[$comment_srl];    
 } else {    
  $root_temp->child[] = &$list[$comment_srl];   // 역순 정렬을 위해 수정 (softmind)    
  $root_count++;          // 역순 정렬을 위해 삽입 (softmind)    
 }    
}    
for($j=0;$j<$root_count;$j++){  // 역순 정렬을 위해 삽입 (softmind) 
-------------------------------> '<='이 아니라 '<'이 맞습니다. 

 $root->child[$j] = $root_temp->child[$root_count-$j-1]; // 역순 정렬을 위해 삽입 (softmind)    
}               // 역순 정렬을 위해 삽입 (softmind)    
$this->_arrangeComment($comment_list, $root->child, 0);    
return $comment_list;  


저 2개만 더 주의하면 역순댓글이 정렬됩니다.

[레벨:6]쏘프티

2008.01.10 11:03:42
*.132.59.231

아 네 감사합니다~

안그래도 <= 가 아니라 < 여서 수정하려고 했는데 레드맨님이 먼저 해주셨네요~
그럼 *^^*  좋은 하루 되세요~

(차후버젼에서 이를 선택할 수 있도록 모듈화 되면 정말 좋을 것 같네요~ ㅋㅋ)

문서 첨부 제한 : 0Byte/ 10.00MB
파일 제한 크기 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 구 동영상 매뉴얼 이동 [1] [레벨:30]zero 2009-09-14 47629
211 Ms 워드로 게시판 글쓰기 imagefile [1] [레벨:3]더하기나무 2007-12-25 4459
210 관리자 포인트 조작 없이 레벨 아이콘 대신 원하는 아이콘 띄우기 imagefile [7] [레벨:2]&#41102;&#41776;&#41 2007-12-24 3867
209 XE설치시 인스톨화면으로 무한 롭백오류 image [1] [레벨:1]cen89co 2007-12-23 3464
208 외부프로그램(페이지)에서 zbxe 로그인 정보 연동하기 imagefile [33] [레벨:1]도데군 2007-12-23 9214
207 회원가입시 추가한 추가정보를 관리자와 회원자신만 보기... [5] [레벨:10]지연아빠 2007-12-22 4886
206 회원이 이름, 닉네임등 정보 변경 못하도록 하기 [7] [레벨:10]지연아빠 2007-12-22 3696
205 IE Toy 사용시 '페이지', '외부페이지' 차단되네요... [3] [레벨:1]폭풍의 전야 2007-12-22 3210
204 xml 포함한 플래쉬를 제로보드xe 에서 적용하는 과정 file [4] [레벨:6]도토리나무 2007-12-20 6612
203 IP대역에 따라 다른 페이지 보여주기 [1] [레벨:10]지연아빠 2007-12-20 3534
» 최근 댓글이 가장 위로 정렬 [2] [레벨:6]쏘프티 2007-12-20 4007
201 ㅎㅎ, 이곳에도 Html 적용이 되네요. imagefile [3] [레벨:1]눈과비 2007-12-14 3615
200 Layout.html 화일의 SEC(순서도)도를 그려봤습니다. imagefile [9] [레벨:3]SensePlus1 2007-12-14 5481
199 페이지가 갑자기 하얀화면으로 나올경우에는 이렇게 해보십시오. imagefile [8] [레벨:6]하나로45 2007-12-13 3791
198 외부페이지에서 위젯사용하지 않고 로그인 정보 다루기. [5] [1] [레벨:6]길치객 2007-12-12 6801
197 외부페이지 사용법 image [8] [레벨:6]길치객 2007-12-11 18325
196 권한없는 모듈을 만났을때 로그인 페이지 띄우기.. [10] [레벨:15]똑디 2007-12-11 5782
195 로그인 안되서 files 폴더 지우셨던 분들!! imagefile [3] [레벨:1]율랑 2007-12-11 4051
194 top 메뉴를 만들어보자 - layout에서 topmenu 항목만들기 imagefile [6] [레벨:3]SensePlus1 2007-12-11 8127
193 음악플레이기 3종세트 설치 방법(수정) imagefile [25] [레벨:9]팔공산 2007-12-10 5220
192 [수정] 최근 이미지 추출에 new 이미지 등이 나타나게 하기... [5] [레벨:29]비나무 2007-12-09 4015



XE Login

OpenID Login