There are two kinds of templates: 'export templates', used during an export to create an external text representation of the data and 'info view templates' that must be HTML and are used by the info view inside the program to display the information for one entry.
On the most basic level the template system works like this: it starts by reading the specified template and looking for keywords it replaces those with the information from the entry to achieve the final version. All the possible keywords can be found on the tags page.
Info view templates have extra tags that only apply to them but otherwise everything that applies to an export template also applies to an info view template so let's build a sample export template to give you an idea of the process.
(Although this sample will use DVDpedia, the template created here will be generic enough that it can be used in any program; wherever you see DVDpedia you can substitute another Pedia's name.)
- For this exercise, we will rename the 'MySilver.html' template to 'MyRating.html' since the finished template won't have much in common with Silver.html.
- Open MyRating.html in your preferred text editor.
- Delete everything from but not including <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> to </body>
- Add the closing </head> tag and the opening <body> tag after content="text/html; charset=iso-8859-1">
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
- [global:collectionName] - The name of the collection.
- [global:sortedBy] - The name of the column the collection is sorted by.
- [global:totalEntries] - Total number of entries in the collection.
- [global:totalNumberOfPages] - Number of pages that will be created by the export.
- [global:dateUpdated] - The current date at the moment of export.
- [global:myEmail] - The "me" addressbook entry email.
- [global:sortedEntry] - Current page separated by a letter or an entire word, depending on the type of export.
- [global:pageNumber] - Current page number.
- [global:previousPageURL] - A URL linking to the next page in the export.
- [global:nextPageURL] - A URL linking to the previous page in the export.
Info view templates only have one entry, therefore the repeat tag is optional and can be ommited.
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--BeginRepeat-->
[key:title]<br />
<!--EndRepeat-->
</body>
</html>
Adding images to be used by your template is done by referencing them as if they where inside a folder called "Images". Let's add a little red man image after every title on our list. To do so, we add an image tag with a source reference to our image named redman.png, located in the Images folder.
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--BeginRepeat-->
[key:title] <img src="images/redman.png" /> <br />
<!--EndRepeat-->
</body>
</html>
- Navigate to the Images folder in ~/Library/Application Support/DVDpedia/Templates/Images.
- Our template is called MyRating.html so we create a new folder and name it "MyRatingImages".
- We copy redman.png into MyRatingImages.
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy--> <br />
<!--EndRepeat-->
</body>
</html>
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE--> <br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy--> <br />
<!--EndRepeat-->
</body>
</html>
To add an index to a template select a location in your template and add the following: <!--IFIndex[Divider: | ]ENDIndex-->. The value given to the [Divider:] tag is what will be added between each generated index value, in this case we used |. There is no limitation to the value, it can even be an image.
<head>
<title>[global:collectionName]</title> <br />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE--> <br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy--> <br />
<!--EndRepeat-->
</body>
</html>
- <meta name="PageSplit" content="SortLetter" />
- <meta name="PageSplit" content="SortName" />
- <meta name="PageSplit" content="[integer]" />
- <meta name="PageBreakAfterEvery" content="[integer]" />
- <meta name="image-export" content="yes" />
- <meta name="image-export" content="no" />
- <meta name="image-width" content="[float]" />
- <meta name="image-height" content="[float]" />
- <meta name="image-compression" content="[float]" />
- <meta name="image-rotation" content="90 or 270 " />
- <meta name="statistics" content="statistics" />
- <meta name="details" content="aTemplate.html" />
- <meta name="includeLocalLinks" content="yes" />
- <meta name="PrintLandscape" content="yes" />
<!--IFlinks
<div class="links">
<ul>
[linksBegin]<li><a href="[link:url]">[link:name]</a></li>
[linksEnd]
</ul>
</div>
ENDlinks-->
For our example template lets add the fact that we don't want cover images exported as we are not using them and they take up space and slow down the export.
<head>
<title>[global:collectionName]</title> <br />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="image-export" content="no" />
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE--> <br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy--> <br />
<!--EndRepeat-->
</body>
</html>
Director: [key:director]
[translate:director]: [key:director]
So let's add my rating to our template but not as an image of stars but a number with a label of my rating that is automatically translated.
<head>
<title>[global:collectionName]</title> <br />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="image-export" content="no" />
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE--> <br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy-->
- [translate:myRating]: [key:myRating] <br />
<!--EndRepeat-->
</body>
</html>
After 'My rating' we'll add a similair products loop and separate each similar product with the HTML list tag <li> </li>. We'll add not only the title of the similar product but a link to that product on Amazon as well. Finally we'll add the <!--IFSP tags for the similar products so that if there are no similar products the list tags will not create an empty line. Notice how the <ul> </ul> are outside of the repeat tags but the list item tags are repeated for each similar product.
<html>
<head>
<title>[global:collectionName]</title> <br />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="image-export" content="no" />
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE-->
<br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy-->
- [translate:myRating]: [key:myRating]
<!--IFSP
<ul>
[similarProductsBegin]<li><a href="[similarProduct:url]">[similarProduct:name]</a></li>[similarProductsEnd]
</ul>
ENDSP-->
<br />
<!--EndRepeat-->
</body>
</html>
- pedia://bruji.com/loadLink= - Loads a link to an external web page.
- pedia://bruji.com/previousEntry - Selects the previous entry.
- pedia://bruji.com/nextEntry - Selects the next entry.
- pedia://bruji.com/setTabView=1 - Sets the main view to cover view.
- pedia://bruji.com/setTabView=0 - Sets the main view to table view.
- pedia://bruji.com/findEntry= - Adds an entry via the search panel.
- pedia://bruji.com/findTitle= - Looks for an entry by title and selects it.
- pedia://bruji.com/perform=returnedClicked - Marks a movie as returned.
- pedia://bruji.com/perform=showLinks - Shows any links connected to the entry.
- pedia://bruji.com/perform=editEntry - Brings up the edit panel.
- pedia://bruji.com/perform=searchForListmania - Searches for possible listmanias the entry belongs to.
- pedia://bruji.com/perform=exportCollection - Brings up the export panel.
- pedia://bruji.com/perform=exportToMac - Brings up the .Mac export panel.
- pedia://bruji.com/perform=exportToIpod - Bring up the iPod export panel.
- pedia://bruji.com/perform=buyAtAmazon - Opens Amazon page to add entry to shopping cart.
- pedia://bruji.com/perform=openAmazon - Opens Amazon entry details page.
- pedia://bruji.com/perform=removeCoverImage - Removes the cover image of the entry.
- pedia://bruji.com/openMovieExternally - Opens any linked movie files.
- pedia://bruji.com/menuPlugin= - Executes any menu plugin by name.
Any images for your template go into the shared image folder Contents/Resources/WebViewFiles/images. To reload your template in the program ctrl-click on the info view and select the template from under the style menu.
<html>
<head>
<title>[global:collectionName]</title> <br />
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="image-export" content="no" />
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="[global:previousPageURL]">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="[global:nextPageURL]">Next</a> END_NEXT_PAGE-->
<br /><br />
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy-->
- [translate:myRating]: [key:myRating]
<!--IFSP
<ul>
[similarProductsBegin]<li><a href="pedia://bruji.com/findEntry=[SP:ASIN]">[similarProduct:name]</a></li>[similarProductsEnd]
</ul>
ENDSP-->
<br />
<!--EndRepeat-->
</body>
</html>
Included with the program:
- Basic- Simple white template, all entries on one page.
- Covers - Just the covers.
- KuzDVDCSS - A CSS template indexed by director.
- SingleEntryPlus - Indexed by theatrical release.
- SortedIndexWithStats - Indexed by title, with statistics.
- StandardsBased - Very clean template, no index but separated alphabetically.
- KuzDVDCovers - A template with a details page. Download & Install
- ChiaScuDVDCovers - Also covers linking to a details page. Download & Install
If you would like to work with the MyRating.html template you can download the final version here. Download and install the example MyRating.html template in: