Override the service rendering


Service protocol

Most of the services are based upon the service protocol when they reference resources such as xslt files.

 Here is the declaration of the sitemap service from the web plugin

<map:match pattern="service/sitemap.html">
	<map:generate type="service-sitemap"/>
	<map:transform type="xslt" src="service://pages/services/sitemap/sitemap.xsl">
		<map:parameter name="contextPath" value="{request:contextPath}"/>
	</map:transform>
	<map:serialize type="xml"/>
</map:match>

This protocol has the following behavior :

  1. Search in the current_skin/templates/current_template/stylesheets/services/plugin_name/uri
  2. Search in the current_skin/services/plugin_name/uri
  3. Take the default xsl in the plugin of the service at sublocation uri

In the preceding example, the file will be searched in the following order

  1. skins/MYSKIN/templates/MYTEMPLATE/stylesheets/services/web/pages/services/sitemap/sitemap.xsl
  2. skins/MYSKIN/services/web/pages/services/sitemap/sitemap.xsl
  3. plugins/web/pages/services/sitemap/sitemap.xsl

XSLT parameter

Since Ametys 3.1, most of the services defined a parameter named 'xslt' to allow the contributor to choose the xslt file to use when rendering.
(note that the src of the xsl is then "service://@xslt")

The list of proposed files depends on the service declaration, but mostly is the '*.xsl' files in the service directory.

For example, the sitemap service will allow the contributor to choose its xsl file between thoses in the directories:

  1. skins/MYSKIN/templates/MYTEMPLATE/stylesheets/services/web/pages/services/sitemap/*.xsl
  2. skins/MYSKIN/services/web/pages/services/sitemap/*.xsl
  3. plugins/web/pages/services/sitemap/*.xsl

Named XSLT

You can give a human readle name to your xsl file, by putting by its side a .xml file (with the same name).
Here is the sitemap.xml file

<?xml version="1.0" encoding="UTF-8"?>
<service>
	<label i18n="true">PLUGINS_WEB_SERVICE_SITEMAP_XSLT_SITEMAP_LABEL</label>
</service>

where the i18n key is in the plugin by default. You have then to specify: skin.MySkin:MYKEY when adding new xsl in your skin.

Kernel

Here is the list of files for services in the kernel.

Service Name

Overriding directory

Default file

Other file (Ametys 3.1)

Support views (Ametys 3.1)

Attachment

skins/MYSKIN/services/web/pages/services/attach

attachments.xsl

attachments-tree.xsl

*.xsl

Content digest

skins/MYSKIN/services/web/pages/services/filtered-contents

list.xsl

 

*.xsl

IFrame

skins/MYSKIN/services/web/pages/services/iframe

iframe.xsl

 

-

Insert content

skins/MYSKIN/services/web/pages/services/insert-content

view.xsl

 

*.xsl

Revamping

skins/MYSKIN/services/web/pages/services/revamping

apply-skin.xsl

 

*.xsl

Search

skins/MYSKIN/services/web/pages/services/search

search.xsl

 

*.xsl

Sitemap

skins/MYSKIN/services/web/pages/services/sitemap

sitemap.xsl

 

*.xsl

Events Calendar

skins/MYSKIN/services/news/pages/services/calendar

calendar.xsl

 

*.xsl

This mean, that

  • if you don't like the html produced by the service Sitemap, you can create the file "skins/MYSKIN/services/web/pages/services/sitemap.xsl" to remplace the default xsl.
  • if you like it, but wants to propose a second rendering to the contributor, you can create the file "skins/MYSKIN/services/web/pages/services/mysitemap.xsl" (with optionally a mysitemap.xml file to name your view)
    See the integration documentation of the plugin to have information on a given plugin.

Reference

When you create your file, you can import the default file if you want to change only a small part.

<xsl:import href="plugin:web://pages/services/sitemap.xsl"/>
Back to top