Sourcefabric Manuals

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

Newscoop 4.3 Cookbook

List article attachments

Purpose:

Create a list of documents attached to the article currently defined in the template environment. If the article was not set the list is empty. The code between {{ list_article_attachments }} and {{ /list_article_attachments }} is repeated for every attachment in the list.

Syntax:

{{ list_article_attachments [length="<integer_value>"]
                            [columns="<integer_value>"]
                            [language="current"] }}
   <list_of_instructions>
{{ /list_article_attachments }}

Filters:

  • all_languages: if true (default) the list will contain all article attachments independent of their language; if false, the list will contain only article attachments that have the language currently defined by the template environment
  • length="<integer_value>": <integer_value> specifies list_length and forces the list to have at most list_length items. If the list contains more items than list_length items the interval of elements to be displayed can be switched using has_previous_elements and has_next_elements from the current_list object
  • columns="<integer_value>": <integer_value> specifies columns_number and sets an environment variable. This is incremented as if the items were placed in a table cell. The counting starts from one and the variable is incremented for every new element. When it reaches the maximum value it is reset to one. This is very useful in building tables of data. For details see current_list
  • language="current": list only attachments that were set as available for all translations and available for the language currently set in the template environment

Inside list_article_attachments the following statements are forbidden:

  • set_language
  • set_default_language
  • unset_language
  • set_publication
  • set_default_publication
  • unset_publication
  • list_issues
  • set_issue
  • set_default_issue
  • set_current_issue
  • unset_issue
  • list_sections
  • set_section
  • set_default_section
  • unset_section
  • list_articles
  • set_article
  • set_default_article
  • unset_article
  • list_article_attachments

Inside the list, the current article attachment is set to the current element of the list. The environment context is restored after the list processing.

Example:

{{ list_article_attachments }}
 {{ if $gimme->current_list->at_beginning }}
  <h4>Downloads:</h4>
 {{ /if }}
  <a href="/attachment/{{ $gimme->attachment->identifier }}">
   {{ $gimme->attachment->file_name }}</a>
  ({{ $gimme->attachment->size_kb }}kb)<br/>
{{ /list_article_attachments }}

Here is an example of how to use the attachment list to play a number of MP3 files:

{{ list_article_attachments }}
 {{ if $gimme->attachment->extension == "mp3" }}
<object type="application/x-shockwave-flash"
data="/templates/radioactive/apps/player_mp3_maxi.swf" width="200" height="20">
<param name="movie" value="/templates/radioactive/apps/player_mp3_maxi.swf" />
<param name="bgcolor" value="#444444"/>
<param name="FlashVars" value="mp3={{ uri options="articleattachment" }}" />
<!-- player home: http://flash-mp3-player.net/ -->
</object>
 {{ /if }}
{{ /list_article_attachments }}

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

You should refresh this page.