테스트 사이트 - 개발 중인 베타 버전입니다

최신글 추출 관련 채택완료

summer1 4년 전 조회 2,420

안녕하세요.

 

https://sir.kr/g5_skin/44469

 

위 게시글 참고해서 최신글 추출했습니다.

 

 

 

현재 본문에 이미지가 없으면 빈 칸으로 나오는데, 저런 게시글의 경우 텍스트만 추출하는 방법이 있을까요?

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

답변 3개

채택된 답변
+20 포인트
e
4년 전

        if($thumb['src']) {

            $img = $thumb['src'];</p>

<p>            $img_content = '<div class="sw_img" style="background-image: url('.$img.');"></div>';

        } else {

            $img_content = '';

        }

        ?>

<style>

</style>



        <div class="swiper-slide" onclick="location.href='<?php echo $list[$i]['href'] ?>';" style="cursor: pointer;">

            <?php echo $img_content; ?></p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

s
summer1
4년 전
감사합니다! 해당 코드대로 적용했더니 원하는대로 됐어요.
하나만 더 여쭤보겠습니다. 이미지 부분은 해결이 됐는데, 이미지가 없을 때는 이미지 높이만큼 본문 내용이 더 길게 추출되도록 하고 싶습니다. 현재는 본문 부분에 높이값을 준 상태인데, 이것도 해결 가능할까요? 새로운 답변에 해당 화면 사진 첨부하겠습니다.
e
eyekiss
4년 전
/lib/latest.lib.php
글자수는 위의 파일에서 처리하는거라.. 처리 방식이 다릅니다.
우선 글자수를 많이 나오게 설정을 하고..
해당 스킨에서 이미지가 있을 경우, 다시 글자를 잘라야겠네요..
s
summer1
4년 전

감사합니다

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

s
4년 전

현재 화면

 

원하는 화면

 

로그인 후 평가할 수 있습니다

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

e
4년 전

/skin/latest/스킨명/latest.skin.php 파일에서 

해당 이미지가 나오는 부분에 if 문을 추가하면 됩니다.

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

s
summer1
4년 전
답변 감사합니다.
조금 더 자세히 알려주실 수 있을까요?
e
eyekiss
4년 전
latest.skin.php 소스가 있어야 알려드릴 수 있습니다.
s
summer1
4년 전
<div class="swiper-container swiper1">
<div class="swiper-wrapper">

<?php
for ($i=0; $i<count($list); $i++) {
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $thumb_width, $thumb_height);

if($thumb['src']) {
$img = $thumb['src'];
} else {
$img = $latest_skin_url.'/img/noimg.png';
$thumb['alt'] = '등록된 이미지가 없습니다.';
}
//$img_content = '<img src="'.$img.'" alt="'.$thumb['alt'].'" >';
$img_content = $img;
?>
<style>
</style>

<div class="swiper-slide" onclick="location.href='<?php echo $list[$i]['href'] ?>';" style="cursor: pointer;">
<div class="sw_img" style="background-image: url('<?php echo $img_content; ?>');">
</div>

<div class="sw_tit">
<?php echo $list[$i]['subject'] ?>
</div>


<div class="sw_content">

<?php echo cut_str(strip_tags($list[$i]['wr_content']), 80)?>

</div>

<div class="sw_date">

<?php echo $list[$i]['datetime'] ?> <br>



<?php if($list[$i]['wr_comment']) { ?>
<?php echo $list[$i]['wr_comment'] ?> 
<?php } ?>


</div>
</div>

<?php } ?>
<?php if (count($list) == 0) { //게시물이 없을 때 ?>
<div class="swiper-slide">
<div class="sw_sub">
등록된 게시물이 없습니다.
</div>
</div>
<?php } ?>


</div>


</div>













이렇게 드리면 될까요?

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

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

로그인