Binders: company

For some reason the idea that I blog belongs to a company has not made it to WordPress. It is very common that a website built on WordPress will have the company name, address, and other expected contact information. Yet, setting up that information cannot be done without hard coding in in your theme. We address that issue by adding a extra option under the Settings menu to allow you enter regular company’s contact information, and expose that information using the {{company}} binder.

company-info

 

 

TODO:

/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.company.php
 * Type:     function
 * Name:     company
 * Purpose:  includes template content
 * -------------------------------------------------------------
 *
 * @param {array} $params 
 *                  $params['name'] Name of the part (e.g. content-main.html)
 *                  $params['assign_to'] Variable withing the template engine to which the content has to be assinged.
 *
 * 
 * REFERENCES:
 *
 * http://www.smarty.net/docs/en/plugins.functions.tpl
 *
 *
 * #EXAMPLE:
 *
 * {{company assign_to="company"}} 
 */

 

 

Binders: category

Getting the list of categories available in a blog is a simple as adding one line:

{{category show="list" assign_to="categories"}}

Although the PHP code that allows accessing the categories is just a WordPress function, the {{category}} binder allow binding the data to a page and access the information directly from the HTML code.

 

Parameters

assign_to

(string) (required*) The name of the object to which you wish to bind the data output.
Default: none

show

(string) (required*) Defined what would you like to display. Valid value for “show” is list which instruct the binder to fetch a list of all categories that are not empty.
Default: none

slug

(string) (required*) The category slug for which you wish to retrieve blog posts. When using the slug parameter the binder will retrieve a list of post instead of a list of categories.
Default: none

 

Return

This binder returns an object with a data property containing the requested information.

 show=”list”

array (size=4)
  'success' => boolean true
  'message' => string 'success' (length=7)
  'action' => string 'appc_post_categories' (length=20)
  'data' => 
    array (size=8)
      0 => 
        array (size=16)
          'term_id' => string '7' (length=1)
          'name' => string 'API' (length=3)
          'slug' => string 'api' (length=3)
          'term_group' => string '0' (length=1)
          'term_taxonomy_id' => string '7' (length=1)
          'taxonomy' => string 'category' (length=8)
          'description' => string '' (length=0)
          'parent' => string '0' (length=1)
          'count' => string '1' (length=1)
          'cat_ID' => string '7' (length=1)
          'category_count' => string '1' (length=1)
          'category_description' => string '' (length=0)
          'cat_name' => string 'API' (length=3)
          'category_nicename' => string 'api' (length=3)
          'category_parent' => string '0' (length=1)
          'permalink' => string 'http://learn.simplifysites.com/category/api/' (length=44)
      1 => ...)

 

slug=”binder”

array (size=15)
  'success' => boolean true
  'action' => string 'appc_post_category_content' (length=26)
  'offset' => int 0
  'post_count' => int 1
  'found_posts' => int 1
  'total_pages' => int 1
  'size' => string '6' (length=1)
  'paged' => int 1
  'has_next' => boolean false
  'next' => null
  'has_prev' => boolean false
  'prev' => null
  'is_first' => boolean true
  'is_last' => boolean true
  'data' => 
    array (size=1)
      0 => 
        array (size=27)
          'ID' => int 27
          'post_author' => string '1' (length=1)
          'post_date' => string '2016-02-11 03:53:55' (length=19)
          'post_date_gmt' => string '2016-02-11 03:53:55' (length=19)
          'post_content' => string '<p>Understanding API</p>
' (length=25)
          'post_title' => string 'API's Overview' (length=14)
          'post_excerpt' => string 'Understanding API' (length=17)
          'post_status' => string 'publish' (length=7)
          'comment_status' => string 'open' (length=4)
          'ping_status' => string 'open' (length=4)
          'post_password' => string '' (length=0)
          'post_name' => string 'api' (length=3)
          'to_ping' => string '' (length=0)
          'pinged' => string '' (length=0)
          'post_modified' => string '2016-02-11 03:53:55' (length=19)
          'post_modified_gmt' => string '2016-02-11 03:53:55' (length=19)
          'post_content_filtered' => string '<p>Understanding API</p>
' (length=25)
          'post_parent' => int 0
          'guid' => string 'http://blog-seed-appcropolis.simplifysites.com/?p=27' (length=52)
          'menu_order' => int 0
          'post_type' => string 'post' (length=4)
          'post_mime_type' => string '' (length=0)
          'comment_count' => string '0' (length=1)
          'filter' => string 'raw' (length=3)
          'post_thumbnail' => string 'http://placehold.it/320x210' (length=27)
          'post_permalink' => string 'http://learn.simplifysites.com/api/' (length=35)
          'post_content_raw' => string 'Understanding API' (length=17)

 

Examples

 

 # EXAMPLE #1: Get post in a given category
 
 {{category slug="news" assign_to="news_posts"}}

 

# EXAMPLE #2: Get posts from a category dynamically
 
{{category slug="{$query.category_name}" assign_to="posts"}}

 

# EXAMPLE #3: get a list of categories

{{category show="list" assign_to="categories"}}
<ul>
{{foreach $categories.data as $cat}}
         <li class="cat-item cat-item-{{$cat.cat_ID}} {{if $cat.slug == $query.category_name}}current-cat{{/if}}">
            <a href="{{$cat.permalink}}" title="{{$cat.description}}">{{$cat.name}}</a> ({{$cat.count}})
        </li>
{{/foreach}}
</ul>

 

 

Binders: bloginfo

If you ever wonder how to access your WordPress blog information, this is the right article for you to read. In general, binders give the power to access information from the database with just a few lines of code.

The binder {{bloginfo}} allows you to access general blog information such as blog name, tagline, date format am other global settings.

Parameters

assign_to

The object to which you wish to assign the fetched data (blog information). By default, the response will include the following information:

  • admin_email
  • date_format
  • blog_name
  • blog_description
  • blog_url
  • posts_per_page
  • template_directory_uri
  • url

 

raw_data

Include all available blog information in the response.

  • siteurl
  • home
  • blogname
  • blogdescription
  • users_can_register
  • admin_email
  • start_of_week
  • use_balanceTags
  • use_smilies
  • require_name_email
  • comments_notify
  • posts_per_rss
  • rss_use_excerpt
  • mailserver_url
  • mailserver_login
  • mailserver_pass
  • mailserver_port
  • default_category
  • default_comment_status
  • default_ping_status
  • default_pingback_flag
  • posts_per_page
  • date_format
  • time_format
  • links_updated_date_format
  • comment_moderation
  • moderation_notify
  • permalink_structure
  • gzipcompression
  • hack_file
  • blog_charset
  • moderation_keys
  • active_plugins
  • category_base
  • ping_sites
  • advanced_edit
  • comment_max_links
  • gmt_offset
  • default_email_category
  • recently_edited
  • template
  • stylesheet
  • comment_whitelist
  • blacklist_keys
  • comment_registration
  • html_type
  • use_trackback
  • default_role
  • db_version
  • uploads_use_yearmonth_folders
  • upload_path
  • blog_public
  • default_link_category
  • show_on_front
  • tag_base
  • show_avatars
  • avatar_rating
  • upload_url_path
  • thumbnail_size_w
  • thumbnail_size_h
  • thumbnail_crop
  • medium_size_w
  • medium_size_h
  • avatar_default
  • large_size_w
  • large_size_h
  • image_default_link_type
  • image_default_size
  • image_default_align
  • close_comments_for_old_posts
  • close_comments_days_old
  • thread_comments
  • thread_comments_depth
  • page_comments
  • comments_per_page
  • default_comments_page
  • comment_order
  • sticky_posts
  • widget_categories
  • widget_text
  • widget_rss
  • uninstall_plugins
  • timezone_string
  • page_for_posts
  • page_on_front
  • default_post_format
  • link_manager_enabled
  • initial_db_version
  • wp_user_roles
  • widget_search
  • widget_recent-posts
  • widget_recent-comments
  • widget_archives
  • widget_meta
  • sidebars_widgets
  • cron
  • auth_key
  • auth_salt
  • logged_in_key
  • logged_in_salt
  • nonce_key
  • nonce_salt
  • can_compress_scripts
  • recently_activated
  • theme_mods_twentyfourteen
  • current_theme
  • theme_mods_appcropolis
  • theme_switched
  • category_children
  • nav_menu_options
  • rewrite_rules
  • template_directory_uri

 

Return

array (size=8)
  'admin_email' => string 'sanraul@appcropolis.com' (length=23)
  'blog_description' => string 'Appcropolis Builder' (length=19)
  'blog_name' => string 'Builder' (length=7)
  'date_format' => string 'F j, Y' (length=6)
  'posts_per_page' => string '100' (length=3)
  'blog_url' => string 'http://localhost:8888/wp' (length=24)
  'url' => string 'http://builder.simplifysites.com' (length=32)
  'template_directory_uri' => string 'http://your_project.simplifysites.com/sites/your_project/wp/wp-content/themes/appcropolis' (length=79)

 

Examples

Print basic blog information

<div>
    {{bloginfo assign_to="info"}}
    {{dump var="info"}}
</div>

 

The output of this request will look like this:

array (size=8)
  'admin_email' => string 'sanraul@appcropolis.com' (length=23)
  'blog_description' => string 'Appcropolis Builder' (length=19)
  'blog_name' => string 'Builder' (length=7)
  'date_format' => string 'F j, Y' (length=6)
  'posts_per_page' => string '100' (length=3)
  'blog_url' => string 'http://localhost:8888/wp' (length=24)
  'url' => string 'http://builder.simplifysites.com' (length=32)
  'template_directory_uri' => string 'http://your_project.simplifysites.com/sites/your_project/wp/wp-content/themes/appcropolis' (length=79)

 

Get all available blog information

<div>
    {{bloginfo raw_data="true" assign_to="info"}}
    {{dump var="info"}}
</div>

 

 

Binders: author

The {{author…}} binder will allow you to access the post author information in a quick and easy way. All what yo have to do is to include the {{author…}} binder and provide the post “user_id” or the “post_id” and voila! The author information will be bound to your page and you can access it from a variable that you can defined.

/**
 * Binds post author data to a template if user_id or post_id were provided.
 *
 * @param {array} $params 
 *                $params['post_id'] 
 *                $params['user_id'] 
 *
 * @return {object}
 * 
 * $response
 * $response['success'] {boolean}
 * $response['data']['ID']
 * $response['data']['user_login']
 * $response['data']['user_nicename']
 * $response['data']['user_email']
 * $response['data']['user_url']
 * $response['data']['display_name']
 * $response['data']['first_name']
 * $response['data']['last_name']
 * $response['data']['nickname']
 * $response['data']['description']
 * $response['data']['aim']
 * $response['data']['yim']
 * $response['data']['jabber']
 * $response['data']['facebook_avatar_thumb']
 * $response['data']['facebook_avatar_full']
 * $response['data']['last_login'] # e.g. 2015-09-30 02:07:56
 * $response['data']['billing_country']
 * ...
 * $response['data']['billing_email']
 * $response['data']['fullname']
 * $response['data']['website']
 * $response['data']['permalink']
 * 
 * @example
 * 
 * Example #1:
 * 
 * {{author user_id="{{$post.post_author}}" assign_to="author"}}
 * 
 * <!-- OR -->
 *
 * {{author post_id="{$post.ID}" assign_to="author"}}
 *
 * <p>by: <strong>{{$author_data.fullname}}</strong><br/>
 * <p>email: <strong>{{$author_data.user_email}}</strong><br/>
 *
 * {{dump var="author_data"}}
 *
 */

 

 

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