Voog.com

Article

Article is a complex content type, with a title, excerpt and body. Articles are available through the blog object, which is a "container" of articles. Articles are available on pages which are of the "News & Blog" type.

See also

Availability of articles

On blog page template, articles in this blog are available as an array:

{% for article in articles %}
  <h1>{{ article.title }}</h1>
  <div>
    {{ article.body }}
  </div>
{% endfor %}

Single article is available on article page (which, in turn, derives "News & Blog" page). On single article page you can use article variable directly. You can also make these values editable on article page: 

<h1>{% editable article.title %}</h1>
<div>
  {% editable article.body %}
</div>

Latest articles

There is also a accessor method on site to get latest 10 articles on site simply by using

{% for article in site.latest_articles %}
  <b>{{ article.title }}</b><br>
{% endfor %}

To display only the latest article, limit keyword in for tag can be used

{% for latest_article in site.latest_articles limit: 1 %}
  <b>{{ latest_article.title }}<b/><br>;
{% endfor %}

Comments

Article may also have comments. See comments function for accessing them and how to use comments.

List of available attributes

author

Returns a person object to access author properties.

body

Returns the body of this article.

comments

Returns all published comments in order of their creation time.

For example, looping through all the comments for current article:

{% for comment in article.comments %}
  <p>{{ comment.body }}</p>
{% endfor %}

comments_count

Number of comments associated with this article

This article has <b>{{ article.comments_count }} comments</b>.

comments_url

Returns URL where new comments for this article should be submitted to in a POST request. Used to build comment forms.

<form action="{{ article.comments_url }}" method="post">...</form>

created_at

Date object representing when this article has been created. Use date filter to format it.

{{ article.created_at | date:"%d.%m.%Y" }}

data

Returns custom data bound to article.

description

Returns the description of this article.

excerpt

Returns the excerpt of this article.

id

Returns related article object ID.

image

Returns an image object that can be attached to article in article settings view.

image?

Returns true or false depending whether image is attached to article.

og_image

Returns an image object that can be attached to article in  settings view. Alias for image.

og_image?

Returns true or false depending whether image is attached to article. Alias for image?.

new_record?

Returns true if article is not saved to database.

Needed for binding additional content areas to article because additional bindings can occur only if article already exists.

{% unless article.new_record? %}
  {% content name="blogarticle_more_content" bind="Article" %}
{% endunless %}

newer

Returns the next (newer) article in the same blog.

{% if article.newer %}
<a href="{{ article.newer.url }}">{{ article.newer.title }}</a>
{% endif %}

older

Returns the previous (older) article in the same blog.

{% if article.older %}
<a href="{{ article.older.url }}">{{ article.older.title }}</a>
{% endif %}

page

Returns page object of blog page containing the article. Useful if multiple blogs and site.latest_articles list should differentiate visually blog origin.

published?

Returns true when article is published. Useful for distinguishing between published articles in the blog list view.

tags

Returns list of tags associated with this article. See tag documentation for more details.

{% editable article.tags %}

tag_names

Returns list of tag names associated with this article. Can be used for quick access to tag name list:

{% for tagname in article.tag_names %}
  {{ tagname }}
{% endfor %}

#=> tag1 tag2

If you want to join tag names with commas, you can also use join filter:

{{ article.tag_names | join: ", " }}

#=> tag1, tag2

tag_names_str

Same as above, but shorter — it returns list of tag names joined with commas immediately.

{{ article.tag_names_str }}

#=> tag1, tag2

title

Returns title of this article.

full_title

Returns article full title for <title> tag value. It's created by article title and site title using article title_separator and title_format with fallback to defaults (site or system default values).

<html><head><title>{{ article.full_title }}</title></head>...</html>

#=> <html><head><title>Current article – My site</title></head>...</html>

title_separator

Returns article <title> tag separator override value used by full_title. When empty then site (or system default) value is used instead.

title_separator_value

Returns <title> tag separator value for article with fallback to defaults (site or system default ("–") values).

title_format

Returns article <title> tag format override value used by full_title. When empty then site (or system default) value is used instead.

Supported values and their corresponding patterns:

  • page_site<page_title> <separator> <site_title>
  • site_page<site_title> <separator> <page_title>
  • page<page_title>
  • site<site_title>

title_format_pattern

Returns <title> tag format patten for article with fallback to defaults (site or system default (<page_title> <separator> <site_title>) values).

updated_at

Date object representing when this article has been updated. Use date filter to format it.

{{ article.updated_at | date: "%d.%m.%Y" }}

url

Full path for this article.

<a href="{{ article.url }}">{{ article.title }}</a>

=> <a href="/blog/article_path">Article title</a>

to_json

Serializes the article to a JSON string.