Filters on contents

  1. Définition
  2. How to creates a static filter
    1. Example 1
    2. Example 2
    3. Example 3
  3. How to creates filters used by the skin (input data)
  4. "Filtered contents aggregator" service
  5. RSS Feed

Définition

A filter is used to retrieve contents matching properties among :

  • zero, one or many content types (article, news, odf, ...)
  • zero, one or many tags (focus, home news, ...)
  • specifics metadata (date, author, ...)

A filter can be restrict to a context. A context defines the context search among :

  • the current site,
  • all sites except the current site,
  • all sites,
  • child pages of the current page. In this case, a depth limitation can be specified

Each filter is linked to a view used to display matching contents :

  • main
  • abstract
  • link
  • others views defines by integrator

A filter can define its own sort criteria.

How to creates a static filter

A static content filter is a extension point of type org.ametys.cms.filter.ContentFilterExtensionPoint.

It can be defined in a plugin.xml file like bellow :

Example 1

The filter bellow :

  • retrieves a maximum of 10 contents
  • of type org.ametys.web.default.Content.article
  • from current site.
  • The contents will be retrieved into their abstract view.
  • The contents are sorted by publication date, then by title.
    	 <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>
			<view>abstract</view>
			<context type="current-site"/>
			<max-result>10</max-result>
                        <sort-information>
                             <sort metadataId="publication-date" ascending="true"/>
                             <sort metadataId="title" ascending="false"/>
                        </sort-information>
    	 	</extension>
    	 </extensions>
Example 2

The filter bellow :

  • retrieves a maximum of 5 contents
  • of type org.ametys.plugins.news.Content.news
  • from all sites,
  • tagged with tag HOME_NEWS AND tag IMPORTANT_NEWS.
  • The contents will be retrieved into their abstract view.
        	 <extensions>
        	 	<extension point="org.ametys.cms.filter.ContentFilterExtensionPoint"
        	 			   class="org.ametys.web.filter.StaticWebContentFilter"
        	 			   id="org.ametys.web.new.RSS">
        	 		<title i18n="false">A la Une</title>
        	 		<description i18n="false">Les actualités à la une</description>
        	 		<content-types>
    			     <type id="org.ametys.plugins.news.Content.news"/>
    			</content-types>
                            <tags>
                                 <tag key="HOME_NEWS"/>
                                 <tag key="IMPORTANT_NEWS"/>
                            </tags>
    			<view>abstract</view>
    			<context type="current-site"/>
    			<max-result>10</max-result>
        	 	</extension>
        	 </extensions>
    
Example 3

The filter bellow :

  • retrieves contents of type org.ametys.web.default.Content.article OR org.ametys.plugins.news.Content.news
  • in the first 5 child pages of the current page,
  • tagged with the tag FOCUS,
  • and whose author's login is 'laurence'
  • The contents will be retrieved into their link view.
            <extensions>
        	 	<extension point="org.ametys.cms.filter.ContentFilterExtensionPoint"
        	 			   class="org.ametys.web.filter.StaticWebContentFilter"
        	 			   id="org.ametys.web.new.RSS">
        	 		<title i18n="false">Les focus</title>
        	 		<description i18n="false">Les focus</description>
        	 		<content-types>
    			     <type id="org.ametys.web.default.Content.article"/>
                                 <type id="org.ametys.plugins.news.Content.news"/>
    			</content-types>
                            <tags>
                                 <tag key="FOCUS"/>
                            </tags>
                            <metadata>
                                <author>laurence</author>
                            </metadata>
    			<view>link</view>
    			<context type="child-pages" depth="5"/>
                            <max-result>10</max-result>
        	 	</extension>
        	 </extensions>
    

How to creates filters used by the skin (input data)

Each template of the skin can define filters to be used in the template. Those filters must be written in the default.xml file in the directory filters of the template directory.

Here bellow an example of such a file :

<?xml version="1.0" encoding="UTF-8"?>
<filters>

	<filter id="focus" target="content">
		<content-types>
			<type id="org.ametys.web.default.Content.article"/>
		</content-types>
		<tags>
		    <tag key="FOCUS"/>
		</tags>
		<view>abstract</view>
		<context type="current-site"/>
		<max-result>5</max-result>
	</filter>

</filters>

The definition of a filter in this file is closed to the definition of a same filter in a plugin.xml file (see above). Do not forget the id of the filter, it will be use in SAX events generating by the input data. You can define as many filters you want in this file.

The inputdata org.ametys.web.tags.inputdata.FilteredContentsInputData reads this file to generate the following SAX events with the contents matching the filters. The defined filter for example will be lead to the following XML :

<inputData>
     <Model>
         <focus>
            <content name="" id="defaultContent://">
                 <html>
                     <head><!-- Here head of the content --> </head>
                     <body>
                          <!-- Here HTML view of the content -->
                     </body>
                 </html>
            </content>


            <content name="" id="defaultContent://">
                 <html>
                     <head><!-- Here head of the content --> </head>
                     <body>
                          <!-- Here HTML view of the content -->
                     </body>
                 </html>
            </content>
         </focus>
     </Model>
</inputData>

"Filtered contents aggregator" service

This service allows to aggregate contents matching a defined filter. The filter is created by the contributor while creating or modifying the service parameters.

The contributor can choose :

  • one content type
  • the search context (among the current site, the other site, all sites or child pages)
  • the language context (among the current sitemap language, the other sitemap languages or all languages)
  • the maximum number of result
  • the view (abstract, main, link)
  • 0 to n content tags

RSS Feed

Each filter is associated with a RSS feed.

There are two kind of public URL for a filter's RSS feed :

  • If the filter needs the page context:


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

    Example : http://monserver.com/plugins/web/default/fr/universite/campus_et_sites/filter/org.ametys.web.article.RSS/rss.xml (http://monserver.com/plugins/web/default/fr/universite/campus_et_sites/filter/org.ametys.web.article.RSS/rss.xml*)
  • If the filter doest NOT need the page context


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

    Example : http://monserver.com/plugins/web/default/fr/filter/org.ametys.web.article.RSS/rss.xml (http://monserver.com/plugins/web/default/fr/filter/org.ametys.web.article.RSS/rss.xml*)

For each "Filtered contents aggregator" service, an internal RSS feed url is available. The url looks like this :


http://[server_name]/plugins/web/[zoneitem_protocol]/[zoneitem_id]/rss.xml

Example : http://monserver.com/plugins/web/zoneItem/7d3fb6d3-24de-435e-9071-6702e8540447/rss.xml.