This type of files can be defined in three location :
in your skins/[skinName]/template/[templateName]/conf directory. If present, this file will be used to list the available content types for pages on which this template is assigned, and for each zone of the page (from 3.4 version only).
in your skins/[skinName]/conf directory : if presents this file will be used to list the available content types for your skin
in your WEB-INF/params directory : if presents this file will be used to list the available content types for your type of site
The structure of the files is different in the first case and in the two others. The global configuration file and the skin configuration file use the simple structure shown above, a simple list of content type IDs.
To define the templates and zones, the file (placed in the template's conf directory) must follow this structure:
Oops !
Copy to clipboard failed. Open the code and copy it manually.
<?xml version="1.0" encoding="UTF-8"?>
<content-types>
<!-- Available content types for the template. -->
<template mode="exclude">
<content-type id="org.ametys.plugins.newsletter.Content.newsletter"/>
</template>
<!-- Available content types for each zone. -->
<zones>
<zone id="default" mode="exclude">
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="right-column" mode="include">
<content-type id="org.ametys.web.default.Content.article"/>
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="media-gallery" mode="include">
<content-type id="org.ametys.plugins.multimedia.Content.photosGallery"/>
<content-type id="org.ametys.plugins.multimedia.Content.multimediaGallery"/>
</zone>
</zones>
</content-types>
<?xml version="1.0" encoding="UTF-8"?>
<content-types>
<!-- Available content types for the template. -->
<template mode="exclude">
<content-type id="org.ametys.plugins.newsletter.Content.newsletter"/>
</template>
<!-- Available content types for each zone. -->
<zones>
<zone id="default" mode="exclude">
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="right-column" mode="include">
<content-type id="org.ametys.web.default.Content.article"/>
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="media-gallery" mode="include">
<content-type id="org.ametys.plugins.multimedia.Content.photosGallery"/>
<content-type id="org.ametys.plugins.multimedia.Content.multimediaGallery"/>
</zone>
</zones>
</content-types>
<?xml version="1.0" encoding="UTF-8"?>
<content-types>
<!-- Available content types for the template. -->
<template mode="exclude">
<content-type id="org.ametys.plugins.newsletter.Content.newsletter"/>
</template>
<!-- Available content types for each zone. -->
<zones>
<zone id="default" mode="exclude">
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="right-column" mode="include">
<content-type id="org.ametys.web.default.Content.article"/>
<content-type id="org.ametys.plugins.news.Content.news"/>
</zone>
<zone id="media-gallery" mode="include">
<content-type id="org.ametys.plugins.multimedia.Content.photosGallery"/>
<content-type id="org.ametys.plugins.multimedia.Content.multimediaGallery"/>
</zone>
</zones>
</content-types>
N.B: the "template" section and the "zones" section are not mandatory, but one at least must be specified. N.B.2: in the same way, all zones are not required to be specified in the "zones" section. Existing zones not mentioned in the file have the same available content types as their template.
Content type render
The content type render is a XSL file. You can have a XSL file per view (or metadataset). You can override views of default content types. Override the content rendering
When you write such a xsl you have the following variables :
Variable name
Description
$back-office
Have the following values '' or 'back' if the user is in the backoffice 'preview' if the user is previewing 'front' on the front.
e.g. when you set statistics on your site, you only wants to have it on the front site, you will the surround it with <xsl:if test="$back-office = 'front'">
$contextPath
The context path. All url have to be prefixed by the context path, but some other variables already includes it (prefix or raw-context)
$pluginName
The name of the plugin declaring the content type. Usefull for resources. <img src="{$contextPath}/plugins/{$pluginName}/resources/img/myimg.png"/>
$siteName
The name of the current site
$prefix
The url prefix for link to pages. <a href="{$prefix}/{$lang}/index.html">
$raw-context
The browser context for links that depends on the preview state, but that are not pages. This is a very limited use, but this is manly to load plugins urls (for rss for examples). e.g. <a href="{$contextPath}/plugin/myplugin.html"> from backoffice and preview will return non validated contents, from frontoffice will return validated contents. <a href="{$raw-context}/plugin/myplugin.html">, from backoffice will return validated contents, from preview and frontoffice will return validated contents.
$lang
The current language. e.g. 'fr', 'en'...
$skin
The current skin name. Usefull to look for resources into the current skin. e.g. <img src="{$contextPath}/{$skin}/resources/img/myimage.png"/>
You also have the following xslt helpers:
How to use a helper
If the helper is named "helper" and its class name is "org.ametys.cms.transformation.xslt.MyHelperComponent", add the helper prefix to your xsl header:
Oops !
Copy to clipboard failed. Open the code and copy it manually.
String type String uri boolean download (false by default)
This method transforms an uri to an url (depending on its type). The list of available values for 'type' depends on your plugin. The defaults are :
type "page", the uri is a page id
type "attachment-content", the uri is a resources id to a file attached to a content.
type "local", the uri is the id of a file attached to a richtext
type "metadata", the uri is the name of a metadata containing a file (with optionnaly the content id as a request parameter named contentId)
type "explorer", the uri is the id of a file in the resources explorerThe value of uri depends on the type. If you want a link to download a file instead of opening it in the browser, set download to true. The basic sample is for pdf or images files that will open in the browser if you set to false.
resolveImage
String type String uri int height int width boolean download (false by default)
This method transform an uri to an url (depending on its type) as above, but limited to images files, because image will be resized according to one or both fixed sizes.
type: see above. uri: see above. height: the desired height or 0 to keep ratio. width: the desired width or 0 to keep ratio. download: see above.
For width and height, you :
specify both to have a image of this exact size : ratio of the image will not be guaranted.
specify only one (the other is '0') : this size will be guaranted, and the other size is free to keep ratio aspect.
specify none (both are '0') : do the same as the 'resolve' method.
resolveBoundedImage
String type String uri int maxHeight int maxWidth boolean download (false by default)
This method transform an uri to an url (depending on its type) as above, but limited to images files, because image will be resized to fit into a given size.
type: see above. uri: see above. maxHeight: the desired maximum height for the image. maxWwidth: the desired maximum width for the image. download: see above.
Add the following prefix to your xsl header xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"
Sample
This sample is extracted from the article xsl file. This part of the file, creates the image tag relative to the illustration.
The illustration is stored as a composite metadata : the image itself (of type file) and its alternative text (of type string). Type 'file' for metadata store the 2 information you need : the type of link and the uri.
Finally, we resolve the url of the image. In this case we know that the image will not be larger or higher than 150 pixels.
Oops !
Copy to clipboard failed. Open the code and copy it manually.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"
exclude-result-prefixes="resolver">
...
<!-- test if metadata is set -->
<xsl:if test="metadata/illustration/image">
<img src="{resolver:resolveBoundedImage(metadata/illustration/image/@type, metadata/illustration/image/@path, 150, 150)}" alt="{metadata/illustration/alt-text}"/>
</xsl:if>
...
<xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"
exclude-result-prefixes="resolver">
...
<!-- test if metadata is set -->
<xsl:if test="metadata/illustration/image">
<img src="{resolver:resolveBoundedImage(metadata/illustration/image/@type, metadata/illustration/image/@path, 150, 150)}" alt="{metadata/illustration/alt-text}"/>
</xsl:if>
...
<xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"
exclude-result-prefixes="resolver">
...
<!-- test if metadata is set -->
<xsl:if test="metadata/illustration/image">
<img src="{resolver:resolveBoundedImage(metadata/illustration/image/@type, metadata/illustration/image/@path, 150, 150)}" alt="{metadata/illustration/alt-text}"/>
</xsl:if>
...
<xsl:stylesheet>
page
To get information from a page
Name
Namespace
page
org.ametys.web.transformation.xslt.PageComponent
Method
Arguments
Description
getTitle
String pageId
or
String sitename String lang String path
Returns the title of a page
pageId : the id of the page.
sitename : the name of the site. lang : the language code path : the path of the page in the lang and in the site
getLongTitle
String pageId
or
String sitename String lang String path
Returns the long title of a page. This will never be empty, because event if it is not filled, it will at least returns the short title
pageId : see above.
sitename: see above. lang: see above. path: see above.
getMetadata
String pageId String metadataName
or
String sitename String lang String path String metadataName
Returns (as a string) the value of the metadata of a page. If the metadata has a problem, will returns empty.
pageId : see above. metadataName : The name of the metadata. Can be / separated for composite metadatas.
sitename: see above. lang: see above. path: see above.
Sample
Suppose you have a metadata that is a page reference, declared as below in your content type.
Oops !
Copy to clipboard failed. Open the code and copy it manually.
Get the readable label of a tag having its key (or name)
siteName : the name of the site. tagName : the key. lang : the lang code ('fr', 'en').
getDescription
String siteName String tagName String lang
Get the readable description of a tag having its key (or name) Since Ametys 3.1.1 siteName : the name of the site. tagName : the key. lang : the lang code ('fr', 'en').
getCategory
String siteName String tagName
Get the id of a category of a tag. This method can helps you to know between all tags affected to a content or a page, which ones are part of a given category.
siteName : the name of the site. tagName : the key.
Sample
This sample displays the name of the tags that are part of a thematic category.
Oops !
Copy to clipboard failed. Open the code and copy it manually.