<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="kr"><![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie10 lt-ie9 lt-ie8" lang="kr"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie10 lt-ie9" lang="kr"><![endif]-->
<!--[if (IE 9)&!(IEMobile)]><html class="no-js lt-ie10" lang="kr"><![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="kr">
<!--<![endif]-->

<head>
    <?php $this->load->view('templates/grace/grace-head-meta')?>
    <?php $this->load->view('templates/grace/grace-head')?>
</head>

<body class="grace">
    <?php $this->load->view('templates/grace/grace-header', ['nav' => preg_replace('/^<[^>]+>|<\/[^>]+>$/', '', hooskNav('grace', '/grace', 2))])?>

    <main id="main" role="main" tabindex="-1">

        <?php if($this->uri->segment(2) == 'search') { ?>
        <div class="container innerHead">
            <form action="" class="grace-search">
                <input type="text" name="keyword" placeholder="검색어를 입력하세요">
                <button type="submit"><i class="fa fa-search"></i></button>
            </form>

            <?php if(count($tags)):?>
            <div class="resourceBoxTag center">
                <div class="grayTxt">추천태그</div>
                <ul>
                    <li><a href="/grace/search?keyword=editorpick">크맵추천</a></li>
                    <?php foreach(array_slice($tags, 0, 7) as $t) {?><li><a
                            href="/grace/search?keyword=<?php echo $t?>"><?php echo $t?></a>
                    </li>
                    <?php }?>

                </ul>
                <!-- <a class="next"></a> -->
            </div>
            <?php endif;?>
        </div>
        <div class="container searchResult">
            <div class="float_left grayTxt">검색결과 <span class="num"><?php echo $totalRows?></span></div>
            <div class="float_right">
                <span><a href="#">전체 콘텐츠</a></span>
                <span><a href="#">전체메뉴</a></span>
                <span><a href="#">추천수</a></span>
            </div>
        </div>

        <?php } else { ?>


        <!--header-->
        <div class="container innerHead">
            은혜로운 성경말씀과 아름다운 이미지의 콜라보
            <div class="resourceBoxTag">
                <ul>
                    <li class="all">전체</li>
                    <li><a href="/grace/search?keyword=editorpick">크맵추천</a></li>
                    <?php foreach(array_slice($tags, 0, 7) as $t) {?><li><a
                            href="/grace/search?keyword=<?php echo $t?>"><?php echo $t?></a>
                    </li>
                    <?php }?>
                </ul>
            </div>
            <!-- <a class="next"></a> -->
        </div>

        <?php }?>

        <!--tab-->
        <?php if(count($posts)): ?>
        <div class="container pb30">
            <ul class="titleBoxTab">
                <li class="current">업데이트 순</li>
                <li>좋아요 순</li>
            </ul>
        </div>
        <?php endif;?>


        <div class="container box">
            <?php for($k=0;$k<count($posts);$k++) { $p = $posts[$k];?>
            <ul class="col col4 col4-2">
                <?php for($i=0;$i<4;$i++) { $k+= $i; if(empty($posts[$k])) {  break; } else { $p = $posts[$k]; } ?>
                <li>
                    <div class="thumb">
                        <a href="<?php echo $p->articleURL?>">
                            <img src="<?php echo getImageUrl($p->postImage)?>">
                        </a>
                    </div>
                    <div class="profile">
                        <a href="<?php echo $p->articleURL?>"><img
                                src="<?php echo getImageUrl($p->pageIcon?$p->pageIcon:$p->postImage)?>"></a>
                        <div class="tit">
                            <a href="<?php echo $p->articleURL?>"><?php echo $p->postTitle?></a>
                        </div>
                        <div class="writer">
                            <a href="<?php echo $p->articleURL?>"><?php echo $p->userName?></a>
                        </div>
                    </div>
                    <div class="ic_area">
                        <div class="float_left">
                            <a class="likes" href="#">
                                <i class="ico" aria-label="좋아요"></i>
                                <span><?php echo $p->likes?></span>
                            </a>
                            <a class="comments" href="#">
                                <i class="ico" aria-label="댓글수"></i>
                                <span><?php echo $p->comments?></span>
                            </a>
                        </div>

                        <div class="float_right">
                            <a href="#" class="hits">
                                <i class="ico" aria-label="조회수"></i>
                                <span><?php echo $p->views?></span>
                            </a>
                        </div>
                    </div>
                </li>
                <?php }?>
            </ul>
            <?php } ?>

            <div class="pagenumber">
                <?php echo $this->pagination->create_links(); ?>
            </div>

        </div>


    </main>

    <?php $this->load->view('templates/grace/grace-footer')?>
    <?php $this->load->view('templates/grace/grace-foot')?>
</body>

</html>