쪽지함 메시지에서 첨부 파일 목록 출력하기
라이믹스에는 커뮤니케이션 모듈 쪽지함에 파일 첨부 기능이 있는데요.
XE에도 탑재된 기능인지는 확인을 안 해봐서 잘 모르겠습니다.
대강 구글링해본 바로는 쪽지 기능에 파일 첨부 팁 같은 게 있었던 것 같기는 해요.
어쨌든 라이믹스에서는 아주 잘 작동합니다.
다만 널리 활용되는 기능은 아니어서 첨부 파일 목록 출력이 기본 스킨에 탑재된 상황은 아니라고 합니다.
https://xetown.com/questions/1388011#comment_1388098
그치만 운영하는 사이트에서 쪽지로 파일을 주고받을 일이 종종 생기게 돼서
일단 급한대로 스킨단에서 파일 목록을 출력해봤습니다.
아주 잘 작동합니다.
구동 환경은 다음과 같습니다.
- 라이믹스 최신 디벨롭 버전(2020-04-28 기준)
- PHP 버전은 7.0대
- 커뮤니케이션 모듈 스킨은 comely_com 스킨 + 레이아웃은 comely_layout
./modules/communication/skins/comely_com/messages.html 파일을 엽니다.
58행에 다음의 코드를 삽입하면 됩니다.
if ( $message->message_type === 'S' ) :
$upload_target_srl = $message->message_srl;
else :
$args = new stdClass;
$args->message_srl = $message->message_srl;
$output = executeQuery('communication.getMessage', $args);
$upload_target_srl = $output->data->related_srl;
endif;
$file_list = getModel('file')->getFiles($upload_target_srl);
}
<div class="atc_file" cond="$file_list" style="position: relative; z-index: 1; font-size: 12px; background-color: #f7f7f7;">
<h3 style="display: inline-block; height: 100%; vertical-align: top; width: 110px; padding: 8px 25px; font-size: 14px;">{$lang->uploaded_file} <span class="pt_col text_ex">{count($file_list)}</span></h3>
<ol style="display: inline-block; list-style: inside decimal; width: calc(100% - 164px); box-sizing: border-box; padding: 8px 10px 0; line-height: 160%; background-color: #fff;">
<li loop="$file_list => $key, $file" style="margin-bottom: 8px;">
<a href="{getUrl('')}{$file->download_url}" class="b_link">{$file->source_filename}</a>
<span class="file_size" style="font-size: 10px;">(File Size: {FileHandler::filesize($file->file_size)}/Download: <span class="pt_col">{number_format($file->download_count)}</span>)</span>
</li>
</ol>
</div>
즉, 메시지 콘텐츠가 나오기 시작하는 <div class="letter_content xe_content">{$message->content}</div>의 바로 윗줄에 넣은 것이죠.
...
일단 제가 쓰는 스킨 기준으로 한 것이어서 class나 style이 좀 지저분해보이기는 한데요.
쪽지함에서 파일 첨부 기능 활용하시는 운영자라면 위 코드에서 불필요한 부분은 잘 걷어내서 활용하시면 될 것 같습니다.
어쨌든 이런 결과물이 나오게 됩니다.
1. 받은 쪽지함, 보관함, 읽지 않은 쪽지함 등에서 메시지를 열었을 때
... 파일 목록도, 본문 삽입된 파일의 링크도 잘 열립니다ㅎ
2. 보낸 쪽지함에서 메시지를 열었을 때
... 파일 목록이 여럿일 때도 잘 나오고요. 캡처하다 우측을 왕창 자르긴 했지만 이미지 삽입도 잘 됐네요.

댓글 7
그나저나 생각해보니 신기하네요. 파일 첨부 기능은 있는데 첨부 파일 목록 출력이 되지 않는 다는 건 말이죠.
분명 파일을 보냈는데 못 받았다 그래서 적잖이 당황을 하게 되더라구요.
어쨌든 저간의 맥락을 빨리 파악할 수 있어서 스킨으로나마 땜빵은 했습니다ㅎㅎ
실제로 도움이 되는 팁들이 만들어져서 정말 덕을 많이 보고 있습니다.
더 부딪치다가 막히는 거 있으면 뚫어볼게요ㅋㅋㅋ
{@
if ( $message->message_type === 'S' ) :
$upload_target_srl = $message->message_srl;
else if :
$args = new stdClass;
$args->message_srl = $message->message_srl;
$output = executeQuery('communication.getMessage', $args);
$upload_target_srl = $output->data->related_srl;
endif;
$file_list = getModel('file')->getFiles($upload_target_srl);
}
/modules/communication/skins/default/messages.html 파일에
윗 부분을 적용하면 서버에러가 발생합니다.
comely_com 스킨에서만 적용되는지요?
해결 : else if : 이 부분을 else : 로 바꾸니 잘 되네요.
헐.. 원래 else if 뒤에 있으나마나한 조건문이 있었는데 글 수정하면서 지운 거거든요.
지우다가 if 는 마저 지우질 못했었네요.
확인 감사합니다~!!