article:list
This tag retrieves the latest n
articles from a publication (using the Publications "all"-section), a
section, a list of sections or a selection of sections. If no section is
specified the current section will be used. If you specify an illegal
attribute (for example, a uniqueName
that does
not exist) the ece_all
section is
used.
Only published articles belonging to published home sections
are retrieved. The retrieved articles are returned in a
java.util.List
Field indexing
The expression
and
field
attributes can only be used on
indexed fields. Field indexing must be
specified on a per-field basis in the publication's
content-type
resource.
To switch on field indexing in a particular content type, you
must add a parameter element that sets the parameter
neo.xredsys.service.article.attribute
to
true
.
<content-type name="news"> ... <parameter name="neo.xredsys.service.article.attribute" value="true"/> </content-type>
Once you have done this, you can specify indexing of individual
fields within the content type by adding
neo.xredsys.service.article.attributeField
parameters to the field definitions:
<field name="priority" type="number"> ... <parameter name="neo.xredsys.service.article.attributeField" value="priority"/> </field>
Note that the value
attribute is set
to the name of the field that is to be indexed. The
neo.xredsys.service.article.attributeField
parameter actually determines the name that you will need to use to
identify the indexed field in the article:list
tag. You could set it to some other name, but you are advised not to do
so.
The examples shown above will ensure that the
priority
field of news
content items is indexed and can be used for selection purposes by
article:list
.
Age
Two properties in the feature
publication resource affect the behavior of this tag:
article.list.age.max
-
Specifies the maximum age (in hours) of content items that may be retrieved, thus potentially overriding the value you specify with the
from
attribute. If you specify afrom
value that equates to an age greater thanarticle.list.age.max
, then it will be ignored, andarticle.list.age.max
will be used instead. The default is 720 hours (=30 days). To disable this limit, setarticle.list.age.max
to-1
. article.list.age.default
-
The default age limit (in hours) that will be used if no
from
value is specified. The default is 720 hours (=30 days). To disable this default (so that there is nofrom
limit if one is not explicitly specified), setarticle.list.age.max
to-1
.
Caching
By default, the result will be cached for 1 minute.
When using the to
property, the result
may not be cached and the tag should be wrapped in a
<util:cache />
, to avoid slowing down the
system too much. Please see the documentation of the
to
property for more information regarding
this.
Syntax
<article:list all="..."? excludeArticleTypes="..."? expression="..."? field="..."? from="..."? homeSectionOnly="..."? id="..." includeArticleTypes="..."? includeSubSections="..."? max="..."? name="..."? onlyLive="..."? property="..."? publicationId="..."? sectionId="..."? sectionUniqueName="..."? sort="..."? to="..."? view="..."? view="..."?/>
Attributes
id
, mandatory, no runtime expressionsA name to identify the selected articles.
from
How far back to list articles. The time could either be defined as hours in the past or as an exact date. The format of the exact date is
yyyy-MM-dd hh:mm
. The exact date should always be in the past.If not defined or set to
-1
the function is disabled.excludeArticleTypes
We will exclude the article type set here. May be a list of comma separated article types.
If neither
includeArticleTypes
orexcludeArticleTypes
are set, all article types will be included in the list.homeSectionOnly
If set to true we will only list articles which has sectionId as homeSection.
includeArticleTypes
We will include the article type set here. May be a list of comma separated article types.
If neither
includeArticleTypes
orexcludeArticleTypes
are set, all article types will be included in the list.includeSubSections
will include articles from sub sections in the list if set to true. The default value is false.
max
How many articles to list
onlyLive
will only list articles that are alive. Default value is set to true. If set to false it will include all states possible for an article.
This attribute has been deprecated and should not be used.
publicationId
The publicationId. If
publicationId
is not set we will use the default publication.sectionId
The id of the sections to get latest articles from. May be a list of comma separated ids.
sectionUniqueName
The name of the sections to get latest articles from. May be a list of comma separated names. It must be the sections uniquename!
name
Specifies the attribute name of the Section we are going to search for Articles.
The bean you specify must be of type Section, or you also have to specify property.
property
Specifies the name of the property to be accessed on the bean specified by the name attribute. You can not use this attribute without the name attribute.
This value may be a simple, indexed, or nested property reference expression. If not specified, the Section identified by name (we then assume the the bean specified is a Section) will be used in the search.
to
If set, the tag will return articles up to this point in time. The time could either be defined in hours in the past or as an exact date. The format of the exact date is
yyyy-MM-dd hh:mm
. The exact date should always be in the past.If not defined, set to
-1
or an exact date is specified, the result will be cached. If set to hours, the result will not be cached.view
a view of sections we will use in the search for the latest articles
sort
What we will sort the article list on. Valid values are:
publishDate
,lastChangedDate
. It is possible to send none to disable the sort function.To decide if the sorting shall be ascending or descending you simply add either +/- before the desired sort criteria.
E.g.
-publishDate
is sorting descending on the published date of the articlesIf this attribute is used together with the
expression
andfield
attributes, you can not sort it by date. It is only possible to specify if the sort will be ascending or descending.view
a view of sections we will use in the search for the latest articles
expression
Is used to get a limited search. This attribute is always used together with the field attribute.
E.g. if you specify the title in field attribute and
a*
in expression you will only get articles that has a title that start with a or A. If you want articles that start with the letters a, b or c you usea-d
.d-f
will include all article with title that starts with d and e. It will not include f.If the field you want to use the expression in is of type
enumeration
you must wrap the expression with the following:<ecs_selection>expression</ecs_selection>
.field
Is used when you want the articles sorted by the specified field. And it is used together with the
expression
attribute.all
Attribute to override the default limit of max age on articles. If this is set to
true
, then all article will be included in the list.This attribute should be used with caution. It may cause large search results and slow jsp pages. It should only be used when you limit the search with for instance
articleType
or asection
that do not contain many articles.
Scripting variable (id)
A scripting variable will be defined using the value of the id
attribute as its name. The variable is of type java.util.List
.