Newscoop 3 Cookbook

List article topics and subtopics

List of Article Topics

Purpose:

Create a list of topics attached to the article currently defined in the template environment. If the article was not set, the list is empty. The topic parameter may not be defined outside the list_article_topics statement; inside the statement however, this parameter is defined. The code between "{{ list_article_topics }}" statement and "{{ /list_article_topics }}" is repeated for every topic in the list.

Syntax:

{{ list_article_topics [length="<integer_value>"]
                       [columns="<integer_value>"] }}
  <list_of_instructions>
{{ /list_article_topics }}

Filters:

  • 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.

Examples:

Taken from Template Pack "The Custodian" (date 2011-03-16) file "article.tpl"

{{ list_article_topics }}
   {{ assign var="topic_cond" value="`$topic_cond` topic is `$gimme->topic->identifier` " }}
{{ /list_article_topics }}

Taken from Template Pack "The Custodian" (date 2011-03-16) file "topic-list.tpl"

{{ list_article_topics }}
 {{ if $gimme->current_list->at_beginning }}
  {{ if $gimme->language->name == "English" }}Related topics
  {{ else }}Temas relacionados
  {{ /if }}
 {{ /if }}
 : {{$gimme->topic->name }}
 {{ if $gimme->current_list->at_end }}
 {{ /if }}
{{ /list_article_topics }}

Inside list_articles 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_topics

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

List of Subtopics

Purpose:

Create a list of subtopics of the topic currently set in the template environment. If the topic was not set it will generate the list of root topics. The topic parameter may not be defined outside the list statement; inside the statement however, this parameter is defined. The code between "{{ list_subtopics }}" statement and "{{ /list_subtopics }}" is repeated for every topic in the list.

Syntax:

{{ list_subtopics [length="<integer_value>"]
                  [columns="<integer_value>"]
                  [order="<order_condition>"] }}
    <list_of_instructions>
{{ /list_subtopics }}

Filters:

  • 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.

<list_of_instructions> may contain any statement except those listed at the end of the page.

  • <order_condition>=
    • byNumber desc|asc
    • byName desc|asc

Inside the list, the data context is defined by the constraints applied to the current topic for every processed line. The data context is restored after the list processing.

Constraints:

Inside list_subtopics the following statements are forbidden:

  • list_subtopics
  • set_topic
  • set_default_topic
  • unset_topic