<?php
$channel_name 		=  $result['channel_name'];
$channel_main_img 	=  $result['main_img'];
$channel_idx 		=  $result['idx'];
$category_idx 		=  $result['category_idx'];
$category_name 		=  $result['category_name'];
$channel_intro 		=  $result['channel_intro'];
$channel_icon 		=  $result['channel_icon'];

$content_type = '3';

?>


<? include_once ('life_header_inc.php');?>



<div class="channel_cont">
	<div class="wrap" style="padding-top:10px;">
		<div class="channel_top">
			<span class="fl">전체글 수 <span class="beachblue"><?=number_format($total_count)?></span></span>
			<span class="fr">
					<button type="button" onclick="location.href='/m/life/channel/<?=$channel_idx?>?search_sort=1'" class="btn br10 <? if($search_sort=='1') { echo 'btn-default_bb'; } else { echo 'btn-default';}?> br20" >최신순</button>
					<button type="button" onclick="location.href='/m/life/channel/<?=$channel_idx?>?search_sort=2'" class="btn br10 <? if($search_sort=='2') { echo 'btn-default_bb'; } else { echo 'btn-default';}?> br20">인기순</button>
				</span>
		</div>
		<div class="channel_boxs" id="life_list" style="margin-bottom: 0 !important;">
			<?

			$i = 1;
			foreach ($list as $val) {
			$title_txt = mb_strimwidth($val['title'], '0', '90', '..', 'utf-8');

			$channel_article_style = '';
			if($i == count($list)) {
				$channel_article_style= 'style="border-bottom:0 !important"';
			}



			?>

			<div class="channel_cont"  style="padding-top:0">
				<span class="channel_photo"><a  onclick="location.href='/m/life/life_view/<?=$val['idx']?>'" style="cursor:pointer"><img src="<?=$val['main_img']?>" class="art-img"></a></span>
				<p class="chtitle2">

					<?if($val['head_title'] != ""):?>


					<a href="/m/life/life_view/<?=$val['idx']?>"><span class="beachblue">[<?=$val['head_title']?>]</span> </a>
				<?endif?>

					<a href="/m/life/life_view/<?=$val['idx']?>"><?=$title_txt?></a></p>
				<p class="ch_txt"><img src="/img/mobile/haert.png"><span class="like"><?=number_format($val['like_count'])?></span><span class="chname pdl25"><a href="/m/life/editor/<?=$val['partner_idx']?>"><?=$val['editor_name']?></a></span></p>
			</div>



			<?}?>

		</div>
		<p style="text-align:center;"><button type="button" class="btn btn-default br20" style="padding:8px 40px; font-size:16px; margin-top:20px;" onclick="channel_list_more();">더보기 <img src="/img/mobile/arr_down.gif" style="vertical-align:middle"></button></p>
	</div>
</div>



<script>
var life_page = 2;
function channel_list_more(){
	var form_data = {
		"sort"					: "<?=$search_sort?>",
		"page"					: life_page,
		"channel_idx"			: "<?=$channel_idx?>"
	};
	$.ajax({
        url: '/m/life/life_list_more',
        async: false,
        type: 'POST',
        dataType: 'HTML',
        data: form_data,
        success: function (rtnHtml) {
        	if(rtnHtml=='') return false;
			var arrHtml = rtnHtml.split("|||||");
			if(arrHtml[0].trim()=='0000') {

				$("#life_list").append(arrHtml[1]);

				if (arrHtml[3] == "N") {
					$("#life_more_btn").hide();
				} else {
					$("#life_more_btn").show();
				}
				life_page++;

			} else {
				alert(arrHtml[1]);
               	return false;
			}
        },
        error: function (rtnHtml) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });
}



</script>
