Submitted Jun 04, 2008 by Volodymyr Muzyka
1. Go to Administration part | Functions
2. Add new XSLT function with following parameters:
· Settings tab:
Name - the function should be called intuitive understanding like "DisplayMedia"
Namespace -the namespace should display function’s purpose like "Composite.Media"
Description -function description
Output type - should be "XHTML"
· Input Parameters
No parameters
· Function calls
Add new function | Composite | Data | Types | IMediaFile | GetIMediaFileXml
· Template
Copy and paste code from DisplayMedia.xsl in attachment
· Preview
In preview mode result will be displayed in HTML format
3. Press “Save” button
4. Edit Page or Template
5. At content area click/right click on Insert button/link | Functions | select created functions
6. Press “OK” button
7. Save changes
Source Code: in attachment
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl in"
xmlns:in="http://www.composite.net/ns/transformation/inpu..."
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<!-- markup placed here will be shown in the head section of the rendered page -->
</head>
<body>
<xsl:apply-templates select="/in:inputs/in:result[@name='GetIMediaFileXml']/IMediaFile[@FolderPath='/MyFolder]" />
</body>
</html>
</xsl:template>
<xsl:template match="IMediaFile[starts-with(@MimeType,'image')]">
<img alt="image" src="/Renderers/ShowMedia.ashx?i={@CompositePath}"/>
</xsl:template>
<xsl:template match="IMediaFile[@MimeType='application/x-shockwave-flash']">
<object>
<param name="movie" value="/Renderers/ShowMedia.ashx?i={@CompositePath}" />
<embed src="/Renderers/ShowMedia.ashx?i={@CompositePath}" width="550" height="400">
</embed>
</object>
</xsl:template>
</xsl:stylesheet>
Note:
1. To get files from Media archive we are using Web Handler: /Renderers/ShowMedia.ashx?i={@CompositePath} .
2. MyFolder - name of the folder with images in Media.
3. This example works only with images and flash. Supported list of MimeTypes could be extended by adding new templates.