Static content filtering


  1. Declaring a static filter
    1. Metadata requirements
      1. Simple conditions
      2. Complex conditions
        1. Complex conditions on date-type metadata
  2. Url of the flow RSS associated with the filter

 

Declaring a static filter

A filter is used to display content with certain properties:

  • zero, one or more types of content (article, news, training offer...)
  • zero, one or more labels (focus, home page news...)
  • specific metadata (date, author, etc.).

A filter can be restricted to a specific context, to limit the search:

  • to the current site
  • to all sites except the current one
  • to all sites
  • daughter pages of the current page (in this case, a depth limit can be specified)

Each filter is linked to a view to display the corresponding content:

  • hand
  • abstract
  • link
  • other views defined by the integrator

For more details on views, please consult the page Declaring a new content type.

The ContentFilterExtensionPoint extension point is used to define a static filter. This is a multiple extension point: in other words, several implementations of this extension point can be active at the same time.

A static filter must be defined in a plugin.xml file. If you need to create a new plugin file, follow the instructions on the plugin Ametys page.

Sample declaration

<extensions>
<extension point="org.ametys.cms.filter.ContentFilterExtensionPoint"
class="org.ametys.web.filter.StaticWebContentFilter"
id="org.ametys.web.article.RSS">
<title i18n="false">Les articles de mon site</title>
<description i18n="false">Le flux RSS des articles</description>
<content-types>
<type id="org.ametys.web.default.Content.article"/>
</content-types>
<tags strict="false" condition="OR">
<tag key="HOME_NEWS"/>
<tag key="IMPORTANT_NEWS"/>
</tags>
<metadata condition="AND">
<metadata id="creator">laurence</metadata>
<metadata id="lastValidationDate" type="date" operator="gte">-7</metadata>
</metadata>
<view>abstract</view>
<context type="current-site"/>
<max-result>10</max-result>
<mask-orphan>true</mask-orphan>
<sort-information>
<sort metadataId="publication-date" ascending="true"/>
<sort metadataId="title" ascending="false"/>
</sort-information>
</extension>
</extensions>

Configuration item

Description

Mandatory

<content-types>

Contains the list of content types searched for
Ex: <type id="org.ametys.web.default.Content.article"/>

no

<tags>

Contains a list of labels that must be applied to the content searched for.

The "condition" attribute defines the type of operator (OR or AND) used:

  • The value AND means that the filter will retrieve content tagged with all the tags mentioned. This is the default value (it will be used if the "condition" attribute is not set).
  • The OR value means that the filter will retrieve content tagged with at least one of the following labels

The "strict" assignment enables or disables top-down autoposting:

  • The value true means that the label search is a strict search, i.e. the content retrieved will only be that bearing the exact labels quoted. This is the default value (in the absence of the "strict" attribute).
  • The value false enables top-down autoposting. The content retrieved will then be content bearing the tags mentioned or one of their child tags.

no

<metadata>

Defines metadata conditions.
The "condition" attribute defines the type of operator (OR or AND) used. The "AND" condition is the default.
See the "Metadata conditions" paragraph dedicated to this element.

no

<view>

Defines the view used to display content.
If not specified, the "main" view is used by default.
Most content has the following views available: main (full view), abstract (summary view) and link (link view). Others may exist (see Graphical rendering of content).

no

<context>

Defines the search context:

  • current-site: the current site
  • other-sites: all sites except the current site
  • all-sites: all sites
  • child-pages: child pages of the current page
  • no-site: for searches on off-site content, such as directory content

yes

<max-result>

Defines the maximum number of items to be filtered.
Unlimited by default.

no

<sort-information>

Determines content sorting order based on metadata
Ex: <sort metadataId="publication-date" ascending="true"/>

no

<mask-orphan>

If "true", orphaned content, i.e. content not attached to any page, is hidden.
false by default.

no

<handle-user-access>

If "true", the filter takes into account the rights (on restricted pages) of the connected user.
false by default.

no

<access-limitation>

Only from Ametys 4.8
If present, the "handle-user-access" configuration is ignored.

3 possible values:

  • page-access: strictly equivalent to handle-user-acces="false", the filter displays content with the same access rights as the current page (caching possible)
  • user-access: strictly equivalent to handle-user-acces="true", the filter displays content according to the current user.
  • anyconnected-access: the filter displays all content accessible to anonymous users or to all connected users. This mode should be used with caution, and only for automatic intranet newsletters.

 

 

 

Metadata requirements

The "metadata" block represents the conditions to be met by content in order to be filtered. Each "metadata" tag in the block indicates a condition on a content metadata.

The "condition" attribute on the "metadata" block represents the operator between the various conditions:

  • The value AND means that the filter will retrieve content whose metadata meets all the declared conditions. This is the default value (it will be used if the "condition" attribute is not set).
  • The value OR means that the filter will retrieve content whose metadata meets at least one condition.

Conditions can be simple (equality test on text values) or complex ("greater than", "less than" test on date values).

Simple conditions

A simple condition is an equality test on a textual value. The name of the metadata is indicated in the "id" attribute and the value tested in the tag content. To retrieve content whose "creator" metadata has the value "laurence", we write :

<metadata>
<metadata id="creator">laurence</metadata>
</metadata>

The following condition block will return content whose creator is "laurence" and whose title is "News".

<metadata condition="AND">
<metadata id="creator">laurence</metadata>
<metadata id="title">Actualité</metadata>
</metadata>

The following condition block will return content whose creator is either "laurence" or "nicolas".

<metadata condition="OR">
<metadata id="creator">laurence</metadata>
<metadata id="creator">nicolas</metadata>
</metadata>

Complex conditions

Complex conditions can be used to represent more advanced tests. To define a complex condition, specify the "type" and "operator" attributes in the "metadata" tag.

  • The "type" attribute specifies the type of metadata.
  • The "operator" attribute specifies the condition operator. The possible values depend on the metadata type.

Currently, only complex "date" conditions are supported.

Complex conditions on date-type metadata

Complex date conditions allow you to perform tests such as "the start date is from yesterday" or "the publication is less than 7 days old".

The operators available are :

  • The "eq" operator to retrieve content whose metadata is equal to the specified date.
  • The "gte" operator to retrieve content whose metadata is after or equal to the specified date.
  • The "gt" operator to retrieve content whose metadata is strictly after the specified date.
  • The "lte" operator to retrieve content whose metadata is before or equal to the specified date.
  • The "lt" operator to retrieve content whose metadata is strictly before the specified date.

Values can be specified in several ways:

  • Either "today" or "now" to indicate the current date.
  • Or a specific day represented in year-month-day format, for example "2013-11-24" for November 24, 2013.
  • Or a day relative to the current date, represented by a positive number for a number of days after the current date, or a negative number for a number of days before the current date. For example, "-1" represents yesterday and "7" represents "7 days from now".

For example, the following condition block will return content published in the last 7 days.

<metadata>
<metadata id="lastValidationDate" type="date" operator="gte">-7</metadata>
</metadata>

The following condition block will return content whose start date ("start-date" metadata) is between yesterday and 3 days from now.

<metadata condition="AND">
<metadata id="start-date" type="date" operator="gte">-1</metadata>
<metadata id="start-date" type="date" operator="lte">3</metadata>
</metadata>

The following condition block will return content with a start date ("start-date" metadata) between today and September 5, 2013.

<metadata condition="AND">
<metadata id="start-date" type="date" operator="gte">today</metadata>
<metadata id="start-date" type="date" operator="lte">2013-09-05</metadata>
</metadata>

Url of the flow RSS associated with the filter

Each filter is associated with a flow RSS. There are 2 types ofurl for the flow RSS of a filter:

  • if the filter requires page context :

    http://[server_name]/plugins/web/[site_name]/[language]/[page_path]/filter/[filter_id]/rss.xml

    Example : http://monserver.com/plugins/web/default/en/universite/campus_et_sites/filter/org.ametys.web.article.RSS/rss.xml
  • if the filter does not require page context :

    http://[server_name]/plugins/web/[site_name]/[language]/filter/[filter_id]/rss.xml

    Example : http://monserver.com/plugins/web/default/en/filter/org.ametys.web.article.RSS/rss.xml
Back to top