Creating a Template
Contents
There are two kinds of templates: 'export templates', used during an export to create an external text representation of the data and 'details view templates' that must be HTML and are used by the details 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.
Details view templates have extra tags that only apply to them but otherwise everything that applies to an export template also applies to a details view template so let's build a sample export template to give you an idea of the process.
- 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>
Details view templates only have one entry, therefore the repeat tags are optional and may be ommited.
Adding the repeat loop tags to the main body of our HTML as well as the keyword for the title ([key:title]) of the entry we have the following template:
<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>
This template will give us a list of all the titles in the collection. The possible keywords for an entry are listed in the tags page. They can also be found in the Help file that is included with each program.
Image Preview:
<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 create a new folder and name it "MyRatingImages".
- 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>
For our sample 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]
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]
<!--EndRepeat-->
</body>
</html>
After 'My Rating' we'll add a links loop and separate each link with the HTML list tag <li> </li>. We'll add not only the title of the link but the URL for the link as well. Finally we'll add the <!--IFlinks tags for the links so that if there are no links 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 link.
<html>
<head>
<title>[global:collectionName]</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="image-export" content="no" />
<meta name="includeLocalLinks" content="yes" />
</head>
<body>
<!--IFIndex[Divider: | ]ENDIndex-->
<!--IF_PREVIOUS_PAGE <a href="">Previous</a> END_PREVIOUS_PAGE-->
<!--IF_NEXT_PAGE <a href="">Next</a> END_NEXT_PAGE-->
<!--BeginRepeat-->
[key:title] <!--IFborrowedBy <img src="images/redman.png" /> [key:borrowedBy] ENDborrowedBy-->
- [translate:myRating]: [key:myRating]
<!--IFlinks
[linksBegin]<a href="[link:url]">[link:name]</a>[linksEnd]
ENDlinks-->
<!--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 grid view.
- pedia://bruji.com/setTabView=0 - Sets the main view to list 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 an entry 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=exportCollection - Brings up the export panel.
- pedia://bruji.com/perform=exportToMac - Brings up the MobileMe export panel.
- pedia://bruji.com/perform=exportToIpod - Bring up the iPod export panel.
- 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/InfoTemplates/Images. To reload your template in the program, ctrl-click the details view and select the template from the Style menu.