{extends file="layout.tpl"}

{block name='init'}
    {assign var="content_id" value={content attr="id"}}
{/block}

{* Body Class *}
{block name="body-class"}page-content{/block}

{* Page Title *}
{block name='no-return-functions' append}
    {if {$content_id}}
        {loop name="content.seo.title" type="content" id={$content_id} limit="1"}
            {$page_title = $META_TITLE}
        {/loop}
    {/if}
{/block}

{* Meta *}
{block name="meta"}
    {if $content_id}
        {loop name="content.seo.meta" type="content" id=$content_id limit="1"}
            {include file="includes/meta-seo.html"}
        {/loop}
    {/if}
{/block}

{* Breadcrumb *}
{block name='no-return-functions' append}
    {if $content_id}
        {$breadcrumbs = []}
        {loop type="content" name="content-breadcrumb" id=$content_id limit="1"}
            {loop name="folder_path" type="folder-path" folder={$DEFAULT_FOLDER}}
                {$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL nofilter}]}
            {/loop}
            {$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL nofilter}]}
        {/loop}
    {/if}
{/block}

{block name="main-content"}
{if $content_id}
    {hook name="content.top" content="$content_id"}
    <div class="main row">
        {hook name="content.main-top" content="$content_id"}
        <article id="content-main" class="col-main col-md-9 col-md-push-3" role="main" aria-labelledby="main-label">

            {hook name="content.content-top" content="$content_id"}

            {loop name="blog.content" type="content" id=$content_id limit="1"}
                <h1 id="main-label" class="page-header">{$TITLE}</h1>
                {if $CHAPO}
                    <div class="chapo">
                        {$CHAPO}
                    </div>
                {/if}
                {if $DESCRIPTION}
                    <div class="description">
                        {$DESCRIPTION nofilter}
                    </div>
                {/if}
                
                {ifloop rel="blog.document"}
                <div class="documents">
                    <ul>
                    {loop name="blog.document"  type="document" content={$ID}}
                    <li><a href="{$DOCUMENT_URL nofilter}" target="_blank">{$TITLE}</a></li>
                    {/loop}  
                    </ul>
                </div>    
                {/ifloop}                    
                
                {if $POSTSCRIPTUM}
                    <small class="postscriptum">
                        {$POSTSCRIPTUM}
                   </small>
                {/if}                
            {/loop}

            {hook name="content.content-bottom" content="$content_id"}

        </article>

        <aside class="col-left col-md-3 col-md-pull-9" role="complementary" itemscope itemtype="http://schema.org/WPSideBar">
            {include file="includes/asides/articles.html"}
        </aside>

        {hook name="content.main-bottom" content="$content_id"}
    </div><!-- /.layout -->
    {hook name="content.bottom" content="$content_id"}
{else}
    <div class="main">
        <article id="content-main" class="col-main" role="main" aria-labelledby="main-label">
            {include file="includes/empty.html"}
        </article>
    </div><!-- /.layout -->
{/if}
{/block}

{block name="stylesheet"}
{hook name="content.stylesheet"}
{/block}

{block name="after-javascript-include"}
{hook name="content.after-javascript-include"}
{/block}

{block name="javascript-initialization"}
{hook name="content.javascript-initialization"}
{/block}
