채택완료

게시판 첨부파일 있을경우 특정 div를 나오게 하고 싶어요

2018-11-06 (화) 10:22:42 5,791

게시판 첨부파일 있을경우 특정 div를 나오게 하고 싶어요

갤러리게시판인데 첨부파일에 이미지를 넣고 이미지가 있으면 특정 div를 나오게 하고 없으면 안나오게 하고 싶어요

답변 1개 / 댓글 1개

채택된 답변
+20 포인트
<?php
// 파일 출력
$v_img_count = count($view['file']);
if($v_img_count) {
echo "<div id=\"bo_v_img\">\n";
 
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
}
}
 
echo "</div>\n";
}
?>
 
view.skin.php 파일에서 위 부분 찾아서
 
<?php
$image_file = false;
// 파일 출력
$v_img_count = count($view['file']);
if($v_img_count) {
echo "<div id=\"bo_v_img\">\n";
 
for ($i=0; $i<=count($view['file']); $i++) {
if ($view['file'][$i]['view']) {
//echo $view['file'][$i]['view'];
echo get_view_thumbnail($view['file'][$i]['view']);
$image_file = true;
}
}
 
echo "</div>\n";
}
?>

위 소스처럼 수정 후

<?php

if($image_file == true){

echo "<div>이미지 있음</div>";

}

?>

이렇게 해보세요.

답변에 대한 댓글 1개

첨부파일을 있을경우 나오게 하고 싶어요ㅠㅠ. 근데 div안에 php문이 있어서 이거는 어떻게 해야하나요?

이미지가 있을경우 아래 코드를 넣고 싶어요
------------------------------------------
<div id="befor_after">
<div id="before">Before</div>

<div id="after">After</div>
<div class="cocoen">


<?php for ($i=0; $i<1; $i++) {
if($i>0 && ($i % $bo_gallery_cols == 0))
$style = 'clear:both;';
else
$style = '';
if ($i == 0) $k = 0;
$k += 1;
if ($k % $bo_gallery_cols == 0) $style .= "margin:0 !important;";
?>




<?php
if ($view['is_notice']) { // 공지사항 ?>

<?php } else {
if(!G5_IS_MOBILE) {
$thumb = get_list_thumbnail($board['bo_table'], $view['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);
$thumb2 = get_list_thumbnail2($board['bo_table'], $view['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);
} else {
$thumb = get_list_thumbnail($board['bo_table'], $view['wr_id'], $board['bo_mobile_gallery_width'], $board['bo_mobile_gallery_height']);
$thumb2 = get_list_thumbnail2($board['bo_table'], $view['wr_id'], $board['bo_mobile_gallery_width'], $board['bo_mobile_gallery_height']);
}
if($thumb['src']) {
if(!G5_IS_MOBILE) {
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
}else{
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$board['bo_mobile_gallery_width'].'" height="'.$board['bo_mobile_gallery_height'].'">';
}

} else {
$img_content = '<span style="width:'.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px">no image</span>';
}

if($thumb2['src']) {
if(!G5_IS_MOBILE) {
$img_content2 = '<img src="'.$thumb2['src'].'" alt="'.$thumb2['alt'].'" width="'.$board['bo_gallery_width'].'" height="'.$board['bo_gallery_height'].'">';
}else{
$img_content2 = '<img src="'.$thumb2['src'].'" alt="'.$thumb2['alt'].'" width="'.$board['bo_mobile_gallery_width'].'" height="'.$board['bo_mobile_gallery_height'].'">';
}

} else {
$img_content2 = '<span style="width:'.$board['bo_gallery_width'].'px;height:'.$board['bo_gallery_height'].'px">no image</span>';
}

echo $img_content;
echo $img_content2;
}
?>




<?php } ?>

</div></div>

답변을 작성하려면 로그인이 필요합니다.