contents 모듈에서 코멘트를 못 읽어오고 있음.
CMS/프레임워크 | Rhymix 2.1 |
---|---|
개발 언어 | PHP 8.4 |
콘텐츠모듈 글보기에서 코멘트 리스트를 불러오는 코드입니다.
경로 : modules/contents/skins/ec_imin/form/file/comment.html
코드 : {@ $_comment_list = $oDocument->getComments() }
해당 기능을 확인해보면 document 모듈에서 getComments() 함수를 불러오고 있습니다.
해당 함수는 comment 모듈에서 getCommentList() 함수를 사용하고 있습니다.
$oComment = getModel('comment'); $_comment_list = $oComment->getCommentList($document_srl); exit(var_dump($_comment_list));
comment.html 파일에서 직접 아래와 같이 적어줬을 때 NULL이 뜹니다. $document_srl에 직접 글번호 넣어줘도 동일합니다.
해당 테이블 찾아보면 코멘트도 있고, 갯수는 정확하게 불러와집니다.
{$oDocument->getCommentcount()} 는 동작을 하고 있습니다.
도대체 어디서부터 디버깅을 해봐야할까요.

eond
Lv. 12
댓글 8
comment.model.php에서 getCommentList() 함수를 보시면
그냥 return; 하는 곳이 5군데 정도 있어요. 이러면 NULL이 나오겠죠.
5군데 중 어느 곳에서 걸려서 return; 했는지 찾아보는 것이 가장 빠르겠습니다.
예를 들어 문서가 존재하지 않거나, 문서의 getCommentCount가 0이라면 그냥 return; 합니다.
comments 테이블과 comments_list 테이블이 서로 맞지 않아서 꼬여 있을 때도 return; 할 수 있습니다.
그나저나 contents 모듈은 어디에서 나온 모듈인가요? 자료실에 안 보이는데... ㅎㅎ
요깄습니다!
https://rhymix.org/pds/1741709
아, 유료 모듈이었군요. 어쩐지 이온디님 글 외에는 거의 언급되는 곳이 없더라구요. ㅎㅎ
같은 값인거 같은데, 불러오는 위치에 따라서 담긴 값들이 다르군요 ㅠ
1.modules/contents/skins/ec_imin/form/file/comment.blade.php
object(DocumentItem)#510 (14) { ["error"]=> int(0) ["message"]=> string(7) "success" ["variables"]=> array(36) { ["document_srl"]=> int(4576) ["module_srl"]=> int(4492) ["category_srl"]=> int(0) ["lang_code"]=> string(2) "ko" ["is_notice"]=> string(1) "N" ["title"]=> string(1) "1" ["title_bold"]=> string(1) "N" ["title_color"]=> string(1) "N" ["content"]=> string(403) " 스크린샷 2025-03-01 오후 11.19.34.png thumb-nurigo.png 1 " ["readed_count"]=> int(0) ["voted_count"]=> int(0) ["blamed_count"]=> int(0) ["comment_count"]=> int(1) ["trackback_count"]=> int(0) ["uploaded_count"]=> int(3) ["password"]=> NULL ["user_id"]=> string(4) "eond" ["user_name"]=> string(9) "이온디" ["nick_name"]=> string(9) "이온디" ["member_srl"]=> int(5) ["email_address"]=> string(13) "eond@eond.com" ["homepage"]=> string(21) "http://eond.com/@eond" ["tags"]=> string(0) "" ["extra_vars"]=> string(19) "O:8:"stdClass":0:{}" ["regdate"]=> string(14) "20250209232739" ["last_update"]=> string(14) "20250302204018" ["last_updater"]=> string(9) "이온디" ["ipaddress"]=> string(3) "::1" ["list_order"]=> int(-4576) ["update_order"]=> int(-4668) ["allow_trackback"]=> string(1) "N" ["notify_message"]=> string(1) "N" ["status"]=> string(6) "PUBLIC" ["comment_status"]=> string(5) "ALLOW" ["apparent_module_srl"]=> int(4492) ["origin_module_srl"]=> int(4492) } ["httpStatusCode"]=> int(200) ["document_srl"]=> int(4576) ["lang_code"]=> string(2) "ko" ["grant_cache"]=> bool(true) ["allow_trackback_status"]=> NULL ["comment_page_navigation"]=> NULL ["columnList"]=> array(0) { } ["allowscriptaccessList"]=> array(0) { } ["allowscriptaccessKey"]=> int(0) ["uploadedFiles"]=> array(1) { ... 중략 ... } }
2. modules/comment/comment.model.php
object(DocumentItem)#829 (30) { ["error"]=> int(0) ["message"]=> string(7) "success" ["variables"]=> array(22) { ["document_srl"]=> int(4576) ["module_srl"]=> int(4492) ["member_srl"]=> int(5) ["category_srl"]=> int(0) ["sale_point"]=> int(0) ["sale_profit"]=> NULL ["purchase_count"]=> NULL ["title"]=> string(1) "1" ["copyright_srl"]=> NULL ["closed"]=> string(0) "" ["sale"]=> NULL ["anonymous"]=> string(0) "" ["adult"]=> string(0) "" ["preview"]=> string(0) "" ["capacity"]=> int(8654) ["extension"]=> string(0) "" ["sale_period_start_date"]=> NULL ["sale_period_end_date"]=> NULL ["regdate"]=> string(14) "20250209232739" ["apparent_module_srl"]=> int(4492) ["origin_module_srl"]=> int(4492) ["title_color"]=> string(0) "" } ["httpStatusCode"]=> int(200) ["document_srl"]=> int(4576) ["lang_code"]=> NULL ["grant_cache"]=> bool(true) ["allow_trackback_status"]=> NULL ["comment_page_navigation"]=> NULL ["columnList"]=> array(0) { } ["allowscriptaccessList"]=> array(0) { } ["allowscriptaccessKey"]=> int(0) ["uploadedFiles"]=> array(0) { } ["extra_eids":protected]=> array(0) { } ["filesize"]=> int(8654) ["file_size"]=> string(6) "8.45KB" ["purchase_count"]=> NULL ["sale_point"]=> string(59) "무료" ["nick_name"]=> string(9) "이온디" ["purchase"]=> bool(true) ["grade_main"]=> array(2) { [1]=> int(0) [2]=> string(22) "0점 / 총 0명 참여" } ["closed"]=> string(0) "" ["anonymous"]=> string(0) "" ["preview"]=> string(0) "" ["sale"]=> NULL ["sale_period_start_date"]=> NULL ["sale_period_end_date"]=> NULL ["title"]=> string(1) "1" ["titleM"]=> string(1) "1" ["thumbnail"]=> string(60) "/eond/files/thumbnails/576/004/100x100.crop.jpg?t=1740915615" }
파일을 무단으로 다운받을 수 있는 정보가 포함되어 있어서 임의로 중략 처리해 드렸습니다.
1번은 첨부파일 정보까지 다 나오는 모양인데, 이건 댓글과는 관련이 없습니다. 중요한 것은 1번에는 comment_count가 나오고, 2번에는 안 나온다는 점입니다.
순정 라이믹스의 comment.model.php를 보면 분명히 503줄 $columnList에 comment_count를 포함해서 쿼리하고 있거든요. 그런데 왜 안 나오는지 이상하네요. 순정 라이믹스에 없는 컬럼도 결과에 보이는 것을 보면, 어딘가 수정해서 쓰고 계시던 것의 부작용이 아닐까 합니다.
1. contents 모듈에서 해당 값을 변형시키는 거 같습니다.
modules/contents/contents.view.php
..
...
}
2. modules/comment/comment.model.php
이제 comment_count 값이 추가되어 나옵니다.
3.
하지만 이 값은 안 뜹니다.
document.item.php를 참조하는데.
// $document_comment_count = $oDocument->comment_count; // 이 값은 불러와지는데 $document_comment_count = $oDocument->getCommentCount(); // 여기서 이게 또 막히네요. exit(var_dump($document_comment_count));
@_@
4. 불러올 때 구조가 다르네요.
object(DocumentItem)#825 (31) { ["error"]=> int(0) ["message"]=> string(7) "success" ["variables"]=> array(22) { ["document_srl"]=> int(4576) ["module_srl"]=> int(4492) ["member_srl"]=> int(5) ["category_srl"]=> int(0) ["sale_point"]=> int(0) ["sale_profit"]=> NULL ["purchase_count"]=> NULL ["title"]=> string(1) "1" ["copyright_srl"]=> NULL ["closed"]=> string(0) "" ["sale"]=> NULL ["anonymous"]=> string(0) "" ["adult"]=> string(0) "" ["preview"]=> string(0) "" ["capacity"]=> int(8654) ["extension"]=> string(0) "" ["sale_period_start_date"]=> NULL ["sale_period_end_date"]=> NULL ["regdate"]=> string(14) "20250209232739" ["apparent_module_srl"]=> int(4492) ["origin_module_srl"]=> int(4492) ["title_color"]=> string(0) "" } ["httpStatusCode"]=> int(200) ["document_srl"]=> int(4576) ["lang_code"]=> NULL ["grant_cache"]=> bool(true) ["allow_trackback_status"]=> NULL ["comment_page_navigation"]=> NULL ["columnList"]=> array(0) { } ["allowscriptaccessList"]=> array(0) { } ["allowscriptaccessKey"]=> int(0) ["uploadedFiles"]=> array(0) { } ["extra_eids":protected]=> array(0) { } ["filesize"]=> int(8654) ["file_size"]=> string(6) "8.45KB" ["purchase_count"]=> NULL ["sale_point"]=> string(59) "무료" ["nick_name"]=> string(9) "이온디" ["purchase"]=> bool(true) ["comment_count"]=> int(1) ["grade_main"]=> array(2) { [1]=> int(0) [2]=> string(22) "0점 / 총 0명 참여" } ["closed"]=> string(0) "" ["anonymous"]=> string(0) "" ["preview"]=> string(0) "" ["sale"]=> NULL ["sale_period_start_date"]=> NULL ["sale_period_end_date"]=> NULL ["title"]=> string(1) "1" ["titleM"]=> string(1) "1" ["thumbnail"]=> string(60) "/eond/files/thumbnails/576/004/100x100.crop.jpg?t=1740915615" }
여기서는 1차 배열 구조에서 comment_count를 불러오는 거라서 가져와지고,
5.
이 값은 저 배열문 보면 variables 안에 comment_count를 가져오는 거라서 못 불러오네요.
modules/document/document.item.php 에서
여기서는 comment_count를 가져오는데, 아마 다시 contents.view.php의
6. 정리하자면
6.1. contents 모듈 스킨의 comment.html에서 document 모듈의 getComments() 를 불러옴
6.2. document 모듈의 getComments() 에서 comment 모듈의 getCommentList()를 불러옴
6.3. comment 모듈의 getCommentList()에서 document 모듈의 getCommentCount()를 불러옴
6.4. document 모듈의 getCommentCount()에서 get으로 comment_count를 가져오는데
이 값이 배열 구조가 달라 못 가져오고 있음. (이건 아마 contents 모듈에서 조작한게 아닐까 추정)
7. 찾아본 해결책은
7.1. document.item.php
여기서 이렇게 해주던지
7.2. modules/comment/comment.model.php
7.3. contents 모듈에서 어떤 변화구가 있었는지 더 삽질하던지 ㅠㅠ
contents 모듈 스킨의 comment.html에서 직접
해당 comment 모듈에서 6.3단계에서 막히니깐 막막하네요.
여기부터 잘못된 것 같습니다.
$oDocument->comment_count라는 변수는 코어의 어디에서도 인식하지 않습니다.
$oDocument->get('comment_count')가 표준입니다.
처음에 댓글 수를 입력해 주는 부분을
로 변경하세요. 컨텐츠 모듈 내부적인 하위호환성을 고려하여 둘 다 유지하셔도 되고요.
역시 코어 개발자는 다르네요. 일타 강사 같습니다. ^-^)b
밤새 씨름했는데 감사합니다.