Blog
From Shopify Wiki
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[blog.handle].articles
Returns a collection of all of this blog's articles regardless of pagination when the blog.liquid template is rendered. Use this construct to get the most recent blog articles to show e.g. in a sidebar in blog.liquid.
<h3>Recent Posts</h3>
<ul>
{% for article in blogs[blog.handle].articles limit: 5 %}
<li>{{ article.title | link_to: article.url }}</li>
{% endfor %}
</ul>
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
To use in article.liquid.
URL of the previous (older) post.
It is false when used in a conditional when there is no previous article.
blog.next_article
To use in article.liquid.
URL of the next (newer) 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>
{% if blog.next_article %}
{% capture next_url %}{{ blog.next_article }}#content{% endcapture %}
<span class="left" style="float:left">{{ '← Next Post' | link_to: next_url }}</span>
{% endif %}
{% if blog.previous_article %}
{% capture prev_url %}{{ blog.previous_article }}#content{% endcapture %}
<span class="right" style="float:right">{{ 'Previous Post →' | link_to: prev_url }}</span>
{% endif %}
</div>
