Blog

From Shopify Wiki

Jump to: navigation, search

The liquid variable blog has the following attributes:

Contents

blog.id

Returns the id of this blog.

blog.handle

This is the accessor for this blog. It is usually the blog's title in underscore with every blank space replaced by a hyphen. "My New Blog" would thus have the handle "my-new-blog".

blog.title

Returns the title of this blog shopify

blog.articles

Returns a collection of all of this blog's articles that match the current paginate options.

blogs.news.articles.size

Returns the number of articles contained in the blog 'news'

blog.articles_count

Returns the count of all of this blog's articles that match the current paginate options.

blog.all_articles

Returns a collection of all of this blog's articles (ignoring pagination).

blog.all_articles_count

Returns the count of all of this blog's articles (ignoring pagination).

blog.url

Returns the relative URL of the blog. See also shop.url.

blog.comments_enabled?

Returns true if comments are enabled for this blog, false otherwise.

blog.previous_article Image:New.gif

To use in article.liquid.

URL of the previous (newer) post.

It is false when used in a conditional when there is no previous article.

blog.next_article Image:New.gif

To use in article.liquid.

URL of the next (older) post.

It is false when used in a conditional when there is no next article.

Some code with ugly inline styles to drop fully-baked in your article.liquid template:

<div id="paginate" style="overflow:hidden">{% if blog.previous_article %}
  <div style="float:left">
  {{ '<< previous post' | link_to: blog.previous_article }}
  </div>{% endif %}{% if blog.next_article %}
  <div style="float:right">
  {{ 'next post >>' | link_to: blog.next_article }}
  </div>{% endif %}
</div>