Difference between revisions of "Liquid Template Variables - article"

From Spiffy Stores Knowledge Base

(New page: The liquid template variable ''article'' has the following attributes: == <code>article.id</code> == Returns the unique internal number of the article. This is normally only for interna...)
 
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
The liquid template variable ''article'' has the following attributes:
+
The Liquid template variable '''article''' has the following attributes:
  
 
== <code>article.id</code> ==
 
== <code>article.id</code> ==
Line 17: Line 17:
 
== <code>article.content</code> ==
 
== <code>article.content</code> ==
  
Returns the content of this page.
+
Returns the content of this article.
 +
 
 +
== <code>article.synopsis</code> ==
 +
 
 +
Returns the content of this article, up to a <code><nowiki>'<!--more-->'</nowiki></code> tag, if it exists.
 +
 
 +
This is useful for providing a summary of blog articles, without including the full text of the article.
 +
 
 +
== <code>article.more_tag?</code> ==
 +
 
 +
Returns true if the <code><nowiki>'<!--more-->'</nowiki></code> tag is present in the article.
  
 
== <code>article.created_at</code> ==
 
== <code>article.created_at</code> ==
Line 23: Line 33:
 
Returns the creation date and time of the article.
 
Returns the creation date and time of the article.
  
<pre>{{ article.created_at | date: "%Y %h" }}</pre>
+
<pre>{{ article.created_at | date: "%Y %b" }}</pre>
 +
 
 +
== <code>article.updated_at</code> ==
 +
 
 +
Returns the date and time that the article was last updated.
 +
 
 +
<pre>Revised on: {{ article.updated_at | date: "%Y %b" }}</pre>
 +
 
 +
== <code>article.published_at</code> ==
 +
 
 +
Returns the date and time that the article was published. Setting the article's visibility to '''hidden''' clears the '''published_at''' timestamp, and setting the article's visibility to '''published''' sets it to the current time.
 +
 
 +
If the '''published_at''' timestamp has not been set, then the '''created_at''' timestamp will be used.
 +
 
 +
<pre>
 +
Published on: {{ article.published_at | date: "%Y %b" }}
 +
</pre>
  
 
== <code>article.url</code> ==
 
== <code>article.url</code> ==
  
 
The is the relative URL address of the article.
 
The is the relative URL address of the article.
 +
 +
== <code>article.blog</code> ==
 +
 +
This is the [[Liquid Template Variables - blog|blog]] that this article belongs to.
  
 
== <code>article.type</code> ==
 
== <code>article.type</code> ==
 +
Returns the type of the object, in this case, ''article''.
 +
== <code>article.comments</code> ==
 +
Returns the published comments for the article. Returns an empty array if comments are disabled.
 +
== <code>article.comments_count</code> ==
 +
Returns the number of published comments for the article.
 +
== <code>article.comments_enabled?</code> ==
 +
Returns <i>true</i> if comments are enabled.
 +
== <code>article.moderated?</code> ==
 +
Returns <i>true</i> if comments for the blog are moderated.
 +
== <code>article.comment_post_url</code> ==
 +
Returns the relative URL for the POST requests that are used to create new comments.
 +
<pre>
 +
{{ article.comment_post_url }}
 +
</pre>
 +
 +
== <code>article.tags</code> ==
 +
Returns all the tags for the article.
 +
<pre>
 +
{% for tag in article.tags %}
 +
  {{ tag }}
 +
{% endfor %}
 +
</pre>
 +
 +
== <code>article.image</code> ==
 +
 +
The image associated with an article is automatically extracted from the article text. It's usual to embed images in an article as this gives you full control on the appearance of the article. When you embed an image within the article text, the URL of the first such image will be returned.
 +
 +
== <code>article.images_count</code> ==
 +
 +
Return the number of images associated with this article. If an image is found within the text of the article, a value of 1 will be returned. Otherwise, 0 is returned.
 +
 +
== Further Reference ==
  
Returns the type of the object, in this case, 'article'.
+
* [[Liquid Basics]]
 +
* [[Liquid Tag Reference]]
 +
* [[Liquid Filter Reference]]
 +
* [[Liquid Variable Reference]]
 +
* [[Liquid Paginate Tag|Pagination ]]

Latest revision as of 13:56, 29 March 2022

The Liquid template variable article has the following attributes:

article.id

Returns the unique internal number of the article.

This is normally only for internal usage.

article.title

Returns the title of this article.

article.author

Returns the name of the author of this article.

article.content

Returns the content of this article.

article.synopsis

Returns the content of this article, up to a '<!--more-->' tag, if it exists.

This is useful for providing a summary of blog articles, without including the full text of the article.

article.more_tag?

Returns true if the '<!--more-->' tag is present in the article.

article.created_at

Returns the creation date and time of the article.

{{ article.created_at | date: "%Y %b" }}

article.updated_at

Returns the date and time that the article was last updated.

Revised on: {{ article.updated_at | date: "%Y %b" }}

article.published_at

Returns the date and time that the article was published. Setting the article's visibility to hidden clears the published_at timestamp, and setting the article's visibility to published sets it to the current time.

If the published_at timestamp has not been set, then the created_at timestamp will be used.

Published on: {{ article.published_at | date: "%Y %b" }}

article.url

The is the relative URL address of the article.

article.blog

This is the blog that this article belongs to.

article.type

Returns the type of the object, in this case, article.

article.comments

Returns the published comments for the article. Returns an empty array if comments are disabled.

article.comments_count

Returns the number of published comments for the article.

article.comments_enabled?

Returns true if comments are enabled.

article.moderated?

Returns true if comments for the blog are moderated.

article.comment_post_url

Returns the relative URL for the POST requests that are used to create new comments.

{{ article.comment_post_url }}

article.tags

Returns all the tags for the article.

{% for tag in article.tags %}
  {{ tag }}
{% endfor %}

article.image

The image associated with an article is automatically extracted from the article text. It's usual to embed images in an article as this gives you full control on the appearance of the article. When you embed an image within the article text, the URL of the first such image will be returned.

article.images_count

Return the number of images associated with this article. If an image is found within the text of the article, a value of 1 will be returned. Otherwise, 0 is returned.

Further Reference