Binders: post

TODO:

/**
 * Appcropolis Site Binder: post
 * 
 * @param {array} $params 
 *                  $params['show'] What to show (e.g. next, previous, blog)
 *                  $params['assign_to'] Variable withing the template engine to which the content has to be assinged.
 *
 * @example
 * EXAMPLE #1: show previous post
 * {post show="previous"}
 * 
 * EXAMPLE #2: show link to blog home page 
 * {post show="blog" label="Back To Blog"}
 * <a href="http://domain.com/blog/">Back To Blog</a>
 * 
 * EXAMPLE #3:  
 * {post show="next"}
 * <a href="http://domain.com/blog/next-post/">The Next Post</a>
 * 
 * EXAMPLE #4: 
 * {post show="previous" class="pull-right btn btn-primary"}
 * <a class="pull-right btn btn-primary" href="http://domain.com/blog/previous-post/">The Previous Post</a>
 * 
 * EXAMPLE #5: 
 * {post show="previous" assign_to="prev_post" class="btn btn-primary"}
 * 
 * <a class="{$prev_post.class}" href="{$prev_post.post_permalink}">{$prev_post.post_permalink}</a>
 * 
 * 
 * EXAMPLE #6:
 * {post show="categories" assign_to="post_categories"}
 * 
 * {dump var="post_categories"}
 * 
 * 	[
 * 		{
 * 			"id": 1,
 * 			"name": "Miscellaneous",
 * 			"cat_permalink": "http://clean-canvas.appcropolis.net/category/misc/"
 * 		}
 * 	]
 * 
 *
 * EXAMPLE #5: 
 * {post show="last" assign_to="post" }
 *
 * 
 * @see http://codex.wordpress.org/Function_Reference/get_adjacent_post
 */

 

END

What Are Binders

In the spirit of simplifying the way we build websites, we removed the need of using PHP code to access the WordPress database and other server side functionality. Instead, we implemented the concept of “binders”.

A binder is simply a token that allows binding data from the database in just a few lines of code.

{{$post.post_title}}

 

You can mix binders with your HTML code which gives you the ability to easily model the UI of your website, while accessing data from the server.

<section class="blog-post">
    <h1>{{$post.post_title}}</h1>
    <p>{{$post.post_content}}<p>
</section>

 

Binders also expose functionality that will normally require to use server side code, allowing us to expose data from a variable that can be access from the pages that you create inside the builder interface

 

{{twitter assign_to="tweets" screen_name="appcropolis" tweets_to_display="4"}}
 <ul>
 {{foreach $tweets.data as $tweet}}
 	<li>
 		<h2>{{$tweet.text}}</h2>	
 		<i>{{$tweet.created_at}}</i>
 		<p>{{$tweet.user.name}} @{{$tweet.user.screen_name}}</p>
 		<a href="{{$tweet.urls.expanded_url}}">
                    {{$tweet.urls.display_url}}
                </a>
 	</li>
 {{/foreach}}
</ul>