How To Get The First Post Category In Post List

TODO:

 

Pulling Post Category Data:

{{post show="categories" assign_to="item_categories" post_id="{{$item.ID}}"}}
<div class="post-category">
    {{if $item_categories.data[0]}} 
    <a href="{{$item_categories.data[0].cat_permalink}}" class="cat-item-{{$item_categories.data[0].cat_ID}}" rel="category tag" title="{{$cat.name}}">{{$item_categories.data[0].name}}</a>
    {{/if}}
</div>

 

 

Full Example:

<!--appc-related-->
<ul class="primary-bg appc-dynamic" id="appc-related">
    {{posts show="all" size="4" assign_to="rel_posts"}}
    {{foreach $rel_posts.data as $item}}
        <li>
            <div class="popular-post-img">
                <a href="#"> <img src="{{$item.post_thumbnail}}" alt="{{$item.post_title}}"></a>
            </div>
            <div class="popular-post-content">
                {{post show="categories" assign_to="item_categories" post_id="{{$item.ID}}"}}
                <div class="post-category">
                    {{if $item_categories.data[0]}} 
                    <a href="{{$item_categories.data[0].cat_permalink}}" class="cat-item-{{$item_categories.data[0].cat_ID}}" rel="category tag" title="{{$cat.name}}">{{$item_categories.data[0].name}}</a>
                    {{/if}}
                </div>
                <h4><a href="{{$item.post_permalink}}">{{$item.post_title}}</a></h4>
                <span>{{date when="{{$post.post_date}}" format="F j, Y"}}</span>
            </div>
        </li>
    {{foreachelse}}
     	<p>No posts.</p>
    {{/foreach}}
</ul><!--./appc-related-->

 

How to Get A List Of Related Posts

TODO:

 

<ul class="appc-dynamic" id="appc-related">      
{{related post_id="{{$post.ID}}" assign_to="rel_posts"}}
{{foreach $rel_posts.data as $item}}
    <li>
        <div class="popular-post-img">
            <a href="{{$item.post_permalink}}"> <img src="{{$item.post_thumbnail}}" alt="{{$item.post_title}}"></a>
        </div>
        <div class="popular-post-content">
            {{post show="categories" assign_to="item_categories" post_id="{{$item.ID}}"}}
            <div class="post-category">
                
                {{if $item_categories.data[0]}} 
                <a href="{{$item_categories.data[0].cat_permalink}}" class="cat-item-{{$item_categories.data[0].cat_ID}}" rel="category tag" title="{{$cat.name}}">{{$item_categories.data[0].name}}</a>
                {{/if}}
            </div>
            <h4><a href="{{$item.post_permalink}}" rel="category tag">{{$item.post_title}}</a></h4>
            <span>{{date when="{{$post.post_date}}" format="F j, Y"}}</span>
        </div>
    </li>
{{foreachelse}}
 	<p>No related posts.</p>
{{/foreach}}
</ul>

 

How To Get A List Of The Most Recent Posts

TODO

 

<!--appc-recent-->
<ul class="primary-bg appc-dynamic" id="appc-recent">
    {{posts show="all" size="4" assign_to="recent_posts"}}
    {{foreach $recent_posts.data as $item}}
        <li>
            <div class="recent-post-img">
                <a href="#"> <img src="{{$item.post_thumbnail}}" alt="{{$item.post_title}}"></a>
            </div>
            <div class="recent-post-content">
                <h4><a href="{{$item.post_permalink}}">{{$item.post_title}}</a></h4>
                <span>{{date when="{{$post.post_date}}" format="F j, Y"}}</span>
            </div>
        </li>
    {{foreachelse}}
     	<p>No posts.</p>
    {{/foreach}}
</ul><!--./appc-recent-->

 

How To Create a Bootstrap Image Gallery

TODO:

NOTE:

 

HTML

<div class="bs-example" data-example-id="simple-carousel">
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
        {{gallery_block id="{{$post.ID}}" assign_to="gallery"}}
        <!--buttons-->
        <ol class="carousel-indicators">
            {{foreach $gallery as $image}}
                <li data-target="#carousel-example-generic" data-slide-to="{{$image@index}}" class="{{if $image_url@index eq 0}}active{{/if}}"></li>
            {{/foreach}}
        </ol>

        <!--slides-->
        <div class="carousel-inner" role="listbox">
            {{foreach $gallery as $image_url}}
            <div class="item {{if $image_url@index eq 0}}active{{/if}}">
                <img alt="First slide [900x500]" src="{{$image_url}}" data-holder-rendered="true">
            </div>
            {{/foreach}}
        </div>
        {{/gallery_block}} 

        <!--arrows-->
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>
</div>

 

 

Cannot Align Vertically? display:flex To The Rescue

Sometimes it might be challenging to vertically centered an element within your web page design. Well, display:flex is a very easy way for you to achieve that goal.

display-flex

 

Here is the HTML code:

<section class="container-fluid my-block">
    <div class="wrapper">
        <h1>Add your code here</h1>
    </div>
</section>

 

CSS Code:

.my-block {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    align-items: center;
    align-content: center;
    height : 300px;
    background-color: #ddd;
    }
.my-block .wrapper {
    width: 100%;
    }
.my-block .wrapper h1 {
    text-align: center;
    width: 100%; 
    }

 

Binders: function

TODO:

Use this binder to create a function that can later on be invoke with {{call…}}.

 

{{function name="promo"}}
    {{if date('Y-m-d') < $expiration}}
    <h1>Get this promotion Now!</h1>
    <p><i>Expires {{$expiration}}</i></p>
    {{/if}}
{{/function}}


{{call promo expiration="2017-03-05"}}