Sourcefabric Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Newscoop 4.3 Cookbook

Ways to create archives

There are different approaches to creating archives. It can be:

  • a list of all Articles
  • a list of Issues
  • a search form to look through all materials

You would usually combine different options or make your own, dependant on your needs.

Placeholder for the Archive page

A placeholder in this context is a series of articles with which to work with or none of our queries will return results. 

The easiest way to create an independent placeholder for our archive page is to create an Issue with a number smaller than the first Issue that contains the content. Let's say it is going to be Issue number 1. Inside this issue we will create the section "Archive" and assign archive.tpl as a section template.

To put the archive link in menu we would use this code:

{{set_issue number="1"}}
{{ list_sections constraints="" }}
<li {{ if ($gimme->section->number == $gimme->default_section->number) }} class="active" {{/if }}>
<a href="{{url options="section"}}" title="">{{ $gimme->section->name }}</a>
</li>
{{ /list_sections }}
<!-- reset issue -->
{{set_current_issue}}

Now we are ready to work on the archive.tpl file.

Paginated list of all Articles sorted by publication date

Listing all articles by publication date is very easy and is in fact the same as the section page. Firstly there is something we should do, list all the articles we will use with the regular list_articles function block but with some options.

{{ list_articles ignore_issue="true" ignore_section="true" length="16" order="byPublishdate desc" constraints=" type is article"}}
...
{{/list_articles}}

ignore_issue is set to "true" because we want to show all articles from all issues. We also use ignore_section and we want to show only articles of type "article". You can of course use your own article types or not use constraints at all.

The trick is to make the paginate function paginate inside our placeholder section. But there is an easy workaround.

{{list_articles ...}}
  ...
  {{if $gimme->current_list->at_end}}
    <!-- we set our issue -->
    {{set_issue number="1"}} <!-- we need also set archive section --> {{set_section number="archive_section_number"}} <!-- after those simple steps we are ready to include file with regular section pagination --> {{ include file="_tpl/pagination.tpl" }} {{/if}} {{/list_articles}}

General Archive based on Issues

This is a very basic and widely used type of Archive. It is convenient even if you have many issues. You can see an example here: http://newscoop-demo.sourcefabric.org/en/jan2011/?tpl=6

For this type of archive we will need to create two files. They can be archive.tpl and archive_issue.tpl.

Lets start with archive.tpl

What we want to do here is to list issues but NOT our placeholder issue number 1. 

{{ list_issues constraints="number not 1" order="bypublishdate desc" }}
  <h3>
    <a href="{{ url options="template archive_issue.tpl" }}">{{ $gimme->issue->name }}</a>
  </h3>
  <h4>
    Published on <time datetime="{{ $gimme->issue->publish_date|date_format:"%Y-%m-%dT%H:%MZ" }}">
                                                 {{ $gimme->issue->publish_date|camp_date_format:"%d %M %Y" }}
                       </time>
  </h4>
{{ /list_issues }}

Notice that in the {{url}} block there is options="template archive_issue.tpl". This block will create a url to the archive_issue template. We don't have to pass an issue number or write options="issue template archive_issue.tpl" because issue is automaticaly set inside the {{list_issues}} loop. 

archive_issue.tpl

In this file we will list sections and articles inside them ordered by publication date. 

<h1>{{ $gimme->issue->name }}</h1> 
<div class="issue-content"> 
{{ list_sections }} 
  {{ list_articles }} 
    {{ if $gimme->current_articles_list->at_beginning }} 
       <h3>{{ $gimme->section->name }}</h3> 
        <ul>
   {{ /if }} 
          <li>
              <a href="{{ url options="article" }}">{{ $gimme->article->name }}</a> 
              <time datetime="{{ $gimme->article->publish_date|date_format:"%Y-%m-%dT%H:%MZ" }}">{{ $gimme->article->publish_date|camp_date_format:"%M %e, %Y" }}</time> 
          </li> 
    {{ if $gimme->current_articles_list->at_end }} 
        </ul> 
    {{ /if }} 
  {{ /list_articles }} 
{{ /list_sections }} 
</div>

And that is it!  

 

Calendar based archive and advanced search

If you have lots of issues, and especially if you plan to maintain the Archive for a long time, you might want to have a combination of different types of archives. You can take a look at an example of how it's done at: http://ganc-chas.by/by/page/archive

Implementing a search-based archive is a good practice, as it gives your readers the opportunity to find the required material quickly. We use an Advanced Search form for that purpose (please take a look at the Template Reference for more information about Advanced Search).

Definitely, you should think in advance about what type of archive you will need. After ten years of work, you would still like to have everything in good order.

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.