title = "Bölüm"
url = "/category/:slug"
layout = "default"
is_hidden = 0

[viewBag]
localeTitle[ru] = "Категория"
localeTitle[en] = "Category"
localeUrl[ru] = "/category/:slug"
localeUrl[en] = "/category/:slug"

[newsPosts]
pageNumber = "{{ :page }}"
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
postFeatured = 0
categoryFilter = "{{ :slug }}"
postPage = "category"
categoryPage = "category"
==
<?php
function onStart(){
    $this["category"] = $this->param('slug');

    $this['lastNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
        ->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
        ->whereNotIn('category_id', [20,21,22])
        ->orderBy('published_at', 'desc')
        ->limit(6)->get();

    }

function onEnd(){
    if($this->newsPosts && $this->newsPosts->category){
        $this->page->title = $this->newsPosts->category->name;
        $this->page->meta_description =  strip_tags($this->newsPosts->category->content)?:$this->newsPosts->category->name;
        $this->page->meta_keywords = $this->newsPosts->category->name;
    }
}
?>
==
<section class="section" id="intro">
    <div class="auto_container">
        <div class="which_page">
            <a href="{{ 'index'|page}}">
                <div class="page_name">
                    {{'Главная'|_}}
                </div>
            </a>
            <div class="slash">\</div>
            <div class="page_name">
                {{category.name}}
            </div>
        </div>
        <div class="section_wrapper">
            <div class="center">
                <div class="title">
                    {{category.name}}
                </div>
                <div class="main_news">
                    {% for item in newsPosts.posts %}
                    <div class="main_news-item">
                        <div class="main_news-date">
                            <span>
                                {{ item.published_at| date("d.m") }}
                            </span>
                            <span>
                                {{ item.published_at| date("Y") }}
                            </span>
                        </div>
                        <div class="main_news-content">
                            <div class="main_news-title">
                                <a href="{{ 'post'|page ({id: item.id, slug: item.slug})}}">
                                    {{ item.title }}
                                </a>
                            </div>
                            <div class="main_news-text">

                                {{ item.introductory|raw }}
                            </div>
                        </div>
                    </div>
                    {% endfor %}
                </div>
                <div class="section_end">
                    <div class="page_num">
                        <a href="newsPosts.posts.previousPageUrl">
                            <div class="direct_btn">
                                    <img src="{{ 'assets/images/left.svg'|theme }}" alt="">
                            </div>
                        </a>
                        <form action="" method="GET">
                            <input type="text" name="page" value="{{newsPosts.posts.currentPage}}" class="input_page">
                        </form>
                        <a href="{{newsPosts.posts.nextPageUrl}}">
                            <div class="direct_btn">
                                    <img src="{{ 'assets/images/right.svg'|theme }}" alt="">
                            </div>
                        </a>
                    </div>
                    <div class="page_list">
                        {{(newsPosts.posts.total/newsPosts.posts.perPage)|round(0,"ceil")}} {{'страниц'|_}}
                    </div>
                </div>

            </div>

            <div class="right_side break">
                <div class="title">
                    {{'Последние новости'|_}}
                </div>

                {% for item in lastNews %}
                    <div class="news_info">
                        <div class="left_date">
                            {{ item.published_at| date("d.m") }}
                        </div>
                        <div class="left_info">
                            <div class="left_title">

                                <a href="{{ 'post'|page ({id: item.id, slug: item.slug})}}">{{item.category.name}}</a>
                            </div>
                            <div class="news_text">
                                {{item.title}}
                            </div>
                        </div>
                    </div>
                {% endfor %}
            </div>

        </div>
    </div>
</section>
