This project has moved. For the latest updates, please go here.

Creating an HTML, XML, or CSV Export Template

This guide is for use as a reference to creating a template to export the media within Media Companion (MC) to an external file. Commonly referred to as an HTML template, due to its original function, this has been extended to include XML and CSV exports.
Examples of each type of output can be found in the html_templates folder of Media Companion. In most cases, it would be easiest to copy and/or modify an existing template.
A template is simply a text file written in the format of the resultant file, and uses “tags” to indicate that MC should substitute it with the relevant information.

>Document Tags
>Image Tags

DOCUMENT TAGS

Before exploring the tags specific to media files, we need to set up the document structure. Some tags are mandatory to enable MC to recognise and execute the templates, while others are optional. Document tags differ from the media tags in that each tag requires a matching closing tag.
At the bare minimum, the template needs to contain:


<title>name_of_template</title>
<<MC HTML Page>>
<</MC HTML Page>>


The <<MC HTML Page>> tag defines the text file as a movie template, and adds it to the Movie toolbar drop-down menu as a template named according to the value of the <title> tag. If either of these tags is missing, the file is considered an ordinary text file, and is ignored.
A <<MC TV HTML Page>> tag identifies the text file as a TV template, and adds it to the TV Show toolbar drop-down menu.
Of course, with only the mandatory tags in place, our export will produce a static and probably blank file! One or more of the optional tags will provide extra information, and a typical HTML template will look something like this:


<title>name_of_template</title>
<<MC HTML Page>>
<<header>>
<meta content="text/html; charset=UTF-8” http-equiv="Content-Type">
<link href="name_of_css_file.css" rel="stylesheet" type="text/css">
<</header>>
<<body>>
<<media_item>>
<</media_item>>
<</body>>
<<footer>><</footer>>
<</MC HTML Page>>

<<css>>
<filename>name_of_css_file.css</filename>
@charset "utf-8";
<</css>>


Typically, XML and CSV templates will only require the <<media_item>> tag (and the best advice is to start from the examples), so we will look at the above example.
Each tag indicates a block typical of HTML documents.
The <<header>> block represents the HTML header and will insert the <html><head></head> HTML tags where appropriate. It also processes any media tags in this block just once, and usually the only value that is useful here it the total number of media items present - any other information is derived from the first media item.
The <<body>> block represents the HTML body and will insert the <body></body> HTML tags where appropriate. Any HTML is output just once, however, the <<body>> block also supports legacy templates as described below.
The <<media_item>> block, as the name suggests, represents each media item in the list. This block is repeated for every media item in the list, and inserts the relevant information for each tag contained within. If the <<media_item>> block is absent, the <<body>> block performs the same function, mainly to support legacy templates.
The <<footer>> block is allowed, but is currently unused.
The <<css>> block creates a separate CSS file that is referenced from the HTML header, designated by the <filename> tag. Obviously, it is imperative that the filenames match!

 

IMAGE TAGS

 

Last edited Apr 20 at 3:36 AM by vbat99, version 8