A template is modeled by one or more XSL files which, using the XML data supplied by CMS, generate HTML to display the web page to the user.

All templates are defined in a folder named templates (cms/skins/[skinName]/templates). This folder contains as many directories as there are templates. Each directory bears the name identifying the template (page or index, for example). A template folder is made up of static resources, a style sheet(template.xsl) and a definition file(template.xml):

DirectoryDetails

  • the template.xml is used to present the template and describe the various zones.
  • the resources folder contains the template's static resources (notably images and style sheets CSS). The integrator is free to organize this folder as he sees fit.
  • the template.xslThe template file, located in the cms/skins/[skinName]/templates/[templateName]/stylesheets folder , combined with dynamic content and data, is used to build the HTML website pages.

There must be at least one named template, which must contain at least one named zone. These are the default values used by the Ametys application. It is also strongly recommended to have a zone in all templates.

In general, certain elements are identical on all pages (the header and footer, for example); in this case, one or more common XSL files, placed in the cms/skins/[skinName]/stylesheets directory and then imported into the various templates.xsl templates allows you to pool the definition of these elements.

Overloading useful templates

The template-default.xsl file in the Ametys kernel contains predefined templates. These can be overridden in the file cms/skins/[skinName]/templates/[templateName]/stylesheets/template.xsl of a template.

The templates defined in this file are :

  • the template favicotemplate, which allows you to define a favicon for your site.
  • the template head-meta-toptemplate, which defines header metadata
  • the template head-js-jquery template for importing jquery files.
  • the template head-css-jquerywhich lets you import a jquery theme
  • the template head-js-piroboxtemplate, which allows you to import Pirobox
  • the template head-css-pirobox which imports the styles used by Pirobox
  • zone and zone-item templates

The favico template

By default, the favicon is extracted from the kernel. To define a new favicon for a given project, it is advisable to override this template and define a Apache site-side rule so that the favicon is always available, even when CMS is not running.

It's essential to place favicon files on the site so that the favicon is always available, even when CMS is down.

We recommend overloading the favicon at a XSL common to all templates.

Favico
The favicon must always be defined in two formats: GIF and ICO, as some browsers only support one or the other.

<xsl:template name="favico"> 
        <link rel="icon" type="image/gif" href="{$uri-prefix}/kernel/resources/img/runtime_favico.gif" /> 
        <link rel="shortcut icon" type="image/x-icon" href="{$uri-prefix}/kernel/resources/img/runtime_favico.ico" /> 
</xsl:template> 

Header metadata

Le template head-meta-top permet de définir les balises <meta> dans l'entête de page. Il est possible de définir des métadonnées par gabarit en surchargeant ce template dans le fichier template.xsl d'un gabarit.

Importing jQuery scripts and themes 

By default, jQuery is imported. It is possible to suppress the jQuery import or to complete this import with plugins, by defining the template XSL named head-js-jquery. This is rarely necessary, as most of the plugins jQuery elements required to display a page have already been imported by content and services.

The jQuery prefix is transformed by $j to avoid conflicts with other libraries, so be sure to keep it if you override the template head-js-jquery.

<script type="text/javascript"> 
    $j = jQuery.noConflict(); 
</script> 

The jQuery theme used by default in Ametys is the "lightness" theme.lightness" themeTo import a different theme, define the new import in a template named head-css-jquery.

Pirobox import

Pirobox is a library built with jQuery for displaying and zooming images. This library is imported by default into Ametys. To change Pirobox launch parameters, modify the template XSL head-js-pirobox.

Like jQuery, it is also possible to modify only the Pirobox theme, the default"Black" theme, by redefining the template XSL head-css-pirobox.

Zones and Zone-items

zone-item-class

This template is used to position CSS classes on item-zones. It must return text only.
The default version sets :

  • first on the first zone-item of the zone
  • even on zone-items pairs
  • last on the last zone-item of the zone
zone-before and zone-after (from Ametys 4.1.2+)

These templates are called up inside each zone: before and after the zone.
The parameters are :

  • count which is the number of zone-items contained in the zone
  • zone-name which is the name of the zone
  • level qui est le niveau hierarchique de la zone (attribut "level" sur le tag <zone>)
  • inherited which is a boolean describing whether the zone content is inherited from its parent page.
zone-item-before and zone-item-after (from Ametys 4.1.2+)

These templates are called for each zone-item in the zone: before and after the zone-item.
The parameters are :

  • position which is the item-zone number among its brothers in the zone
  • count which is the number of zone-items contained in the zone
  • zone-name which is the name of the zone
  • level qui est le niveau hierarchique de la zone (attribut "level" sur le tag <zone>)
  • inherited which is a boolean describing whether the zone content is inherited from its parent page.
  • id which is the unique identifier of the zone-item (note that this identifier contains characters that are forbidden for use as an identifier html)
  • type which is the zone-item type among :
    • CONTENT if the type is a content
    • SERVICE if the type is a service
    • WRAPPER if the type is html coated
  • content-id, which is the content identifier if the type is CONTENT
  • content-type which is the (first) content type of the content if the type is CONTENT
  • service, which is the identifier of the service type if the type is SERVICE
Back to top