Article
Article is a complex content type, with title, excerpt and body. Articles are available through blog object, which is a "container" of articles.
Availability of articles
See also
Availability of articles
{% for article in articles %} <h1>{{ article.title }}</h1> <hr /> {{ article.body }} {% 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:
<h1>{{ article.title }}</h1> <hr /> {{ article.body }}
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/> {% endfor %}
Comments
Article may also have comments. See comments function for accessing them and how to use comments.
Available properties
author
Returns person object to access author properties
body
Returns 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
excerpt
Returns excerpt of this article
new_record?
{% unless article.new_record? %} {% content name="blogarticle_more_content" bind="Article" %} {% endunless %}
page
Returns page object of blog page containing the article. Useful if multiple blogs and site.latest_articles list should differentiate visually blog origin.
tags
tag_names
{% 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.
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
<a href="{{ article.url }}">{{ article.title }}</a>
=> <a href="/blog/article_path">Article title</a>