content/news.template.html

Follow

news (array)

news contents can only be accessed via a loop. Each subarray contains the following references.

TermData TypeTypical OutputDescription
id int My news id The news id
title varchar My news item The news title
url varchar /blog/my-news-article The url for the news article
image varchar /images/blog_images/news-image.jpg The image title
name varchar The news name The news name
body html My news content in HTML etc.. The news content in HTML
author.name varchar John Doe The name of the author
date.created varchar Tue 11th June 2011, 13:45 The date the article was created
date.edited varchar Tue 11th June 2011, 13:45 The date the article was edited

Usage (List of articles)

If you want to simply display a list of news articles as shown below, simply use the code below within the content/news.template.html file.

{% for news_item in news %}
<div class="row">
<div class="col-sm-12">
<h2><a name="{{ news_item.id }}">
{{ news_item.title }}</a></h2> <p>{{ news_item.body }}</p>
</div>
</div> {% endfor %}
 

Usage (Blog Style with Link to Articles)

If you want to display a list of article tiles, with links to each article, you can do so as follows.  Please note that blog and news articles in detail use the content.template file rather than this template.

 {% set holdingImage = '/images/blog_images/blog_P2L8mF3jo2_iphone-624709_1920.jpg' %}
{% for article in news %}
{% if loop.index == 1 %}

<div class="col-sm-12">
<a href="{{ article.url }}" title="{{ article.title }}">
<img src="{% if article.image %}{{ article.image }}{% else %}{{ holdingImage }}{% endif %}" alt="{{ article.title }}" class="img-responsive" />
</a>
<span class="text-lg">
<a href="{{ article.url }}" title="{{ article.title }}">
{{ article.title }}
</a>
</span>
<span class="text-sm" style="color:#999"><br>by {{ article.author.name }} >> {{ article.date.created|date("l jS M Y") }}</span>
<div class="divider-clear-20px"></div>
</div>
{% else %}

<div class="col-sm-6">
<div style="text-align:center" >
<a href="{{ article.url }}" title="{{ article.title }}">
<img style="max-height:300px; width:100%;" src="{% if article.image %}{{ article.image }}{% else %}{{ holdingImage }}{% endif %}" alt="{{ article.title }}" class="img-responsive" />
</a>
</div>
<span class="text-lg">
<a href="{{ article.url }}" title="{{ article.title }}">
{{ article.title }}
</a>
</span>
<span class="text-sm" style="color:#999"><br>by {{ article.author.name }} >> {{ article.date.created|date("l jS M Y") }}</span>
<div class="divider-clear-15px"></div>
</div>
{% endif %}
{% endfor %}
Have more questions? Submit a request

Comments

Powered by Zendesk