안녕하세요
일전에
https://xetown.com/questions/1685046
위 글에서 문의 드려서 답변 받은 방법으로
게시판 목록에서 최초 첫번째 게시물에서만 썸네일을 출력하는 방법을 사용 했었는데요
오늘 다른 변경사항이 없는데 출력이 안되서요
다른 스킨에 적용해봐도 도통 해결이 안되서 다시 한번 문의 드려봅니다 ㅜㅜ
람보님께서 설명해주신 방법
위 방법대로 하지말고
어차피 반복문은 몇번 돌리던 상관없으니 썸네일이 있는 이미지의 제일 첫번째 데이터만 가져오도록 하면되겠습니다.
해당 스킨 출력하는 부분 위에서
<!--@foreach($documents as $no => $document)-->
<!--@if($document->getThumbnail())-->
{
$firstTh = $document->getThumbnail;
braek;
}
<!--@end-->
<!--@end-->
이렇게 해서
<!--@if($firstTh)-->
이미지 출력
<!--@end-->
뭐 이런식?
테스트는 안해봣는데 템플릿에서 break가 안먹히면 그냥 $fristTh가 있으면 continue 으로 넘어가게 하거나 등등.. 방법은 많이있긴합니다.
상황에 따라 골라서 구현하시면 되겠습니다.
위 방법대로 하면 목록 게시판 전체 썸네일이 모두 사라지더라구요 ㅜㅜ
윤삼님께서 설명해주신 방법
<li loop="$document_list=>$no,$document">
<!--@if(($total_count - $no) % $module_info->list_count === 0 && $list_config['thumbnail'] && $document->thumbnailExists())-->
<img src="{$document->getThumbnail()}" />
<!--@end-->
블라블라~~ 기타 문서 정보들
</li>
위 방법대로 적용하니
DivisionByZeroError #0 "Modulo by zero" in modules/board/skins/eoshub/templates/card/card-item.html on line 34
이런 에러가 발생해버리네요
그전에는 잘되었는데 ㅜㅜ
현재 제 사이트에 적용된 코드 입니다
{@
// 썸네일 크기
$post_item_thumbnail_width = '240px';
$post_item_thumbnail_height = '160px';
if($mi->card_thumb_width)
$post_item_thumbnail_width = $mi->card_thumb_width;
if($mi->card_thumb_height)
$post_item_thumbnail_height = $mi->card_thumb_height;
if($mi->card_thumb_blur == 'Y')
$post_item_blur = 'app-post-item--blur';
}
<li loop="$document_list=>$no,$document">
<div class="app-post-item-wrap">
{@
// 아이템 타입
$post_item_type = 'app-post-item--base';
if(!$document->thumbnailExists()) // 썸네일이 없을 때
$post_item_type = 'app-post-item--text'; // 텍스트 타입으로 지정
elseif(in_array('secret', $document->getExtraImages())) // 비밀글일 때
$post_item_type = 'app-post-item--text'; // 텍스트 타입으로 지정
elseif(!$document->getSummary(80)) // 요약글이 없을 때
$post_item_type = 'app-post-item--image'; // 이미지 타입으로 지정
// 비밀글 상태
$post_item_secret = '';
if(in_array('secret', $document->getExtraImages()))
$post_item_secret = 'app-post-item--secret';
}
<a class="app-post-item {$post_item_type} {$post_item_secret} {$post_item_blur}" href="{getUrl('document_srl',$document->document_srl, 'listStyle', $listStyle, 'cpage','')}">
<include target="card-item-status.html" />
{@ // 썸네일 영역 }
<!--@if($document->thumbnailExists() && !$post_item_secret)-->
<div class="app-post-item__thumbnail">
<!--@if(($total_count - $no) % $module_info->list_count === 0 && $list_config['thumbnail'] && $document->thumbnailExists())-->
<img src="{$document->getThumbnail($module_info->card_thumb_width, 'auto', 'ratio')}"/>
<!--@end-->
이하 스킨 내용물들
블라블라
여기에서 잘못된 내용이 있을까요? ㅜㅜ
읽어봐주셔서 감사합니다!
DivisionByZeroError 자체가 숫자를 0으로 나눌수 없다는 그런 에러거든요.
앞뒤의 숫자가 어떻게 나오는지 변수자체에서 확인하고 디버깅 해봐야 합니다.