Permlink Replies: 5 - Pages: 1 - Last Post: 13-Jan-2004 00:33 Last Post By: kaya Threads: [ Previous | Next ]
davidekholm

Posts: 3,455
Registered: 18-Oct-2002
Proccess your own template files
Posted: 06-Feb-2003 09:49
  Click to reply to this thread Reply
This is a tip for skin creators. You are by now aware that JAlbum processes the index.htt and slide.htt files contained in the skin directory when generating albums, but how about having JAlbum process yet another template file for you? You might for example want the original image linked from a slide page to show up inside another html page with navigation buttons an all instead of just the plain JPEG image. Try out the new API funtion
engine.processTemplateFile(java.io.File source, java.io.File dest, java.util.Map vars)
to have this effect. It accepts an input File object, an output File object and a Map object of variables to be expanded.
Graeme Boyd
Re: Proccess your own template files
Posted: 23-Apr-2003 04:35   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
This works from the "slides.htt" template, but does not work from the index.htt page as indicated below (from my index.htt template).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>$title</title>
<LINK HREF="$styleFile" rel=stylesheet>
<script type="text/javascript">
function closeup(url) {
window.open(url, "screen","");
}
</script>
</head>

<BODY ID="index">

<! -- link "dirIndex.htt" page -->
<%
File template = new File(skinDirectory, "dirIndex.htt");
if (template.exists()) {
dirIndexPage = "dirIndex"+engine.getPageExtension();
alert(dirIndexPage);
engine.processTemplateFile(template,
new File(outputDirectory,dirIndexPage), current);
}
%>
-------
The error message I get looks like:

Error evaluating line 4 of <ja:eval> element:
engine .processTemplateFile ( template , new File ( outputDirectory , dirIndexPage ) , current )

Error details:
Sourced file: <Inline eval of:
File template = new File(skinDirectory, "dirIndex.htt");
if (template.exists()) {
dirIndexPage = "dirIndex"+engine.getPageExtension();
engine.processTemplateFile(template,
new File(outputDirectory,dirIndexPage), current);
}
; > : Error in method invocation: Attempt to pass void argument (position 2) to method: processTemplateFile

The problem is that "current" is undefined at this point in the index.htt template (this is causing me other problems as I want to link to the $firstPage at this point as well).

So how do I get a second index like template file to run???

Graeme
davidekholm

Posts: 3,455
Registered: 18-Oct-2002
Re: Proccess your own template files
Posted: 23-Apr-2003 10:23   in response to: Graeme Boyd in response to: Graeme Boyd
  Click to reply to this thread Reply
$current (or current if withing sciptlets) is only defined if you put the calling code within a ja:coliterator. Does that help?
Graeme
Re: Proccess your own template files
Posted: 24-May-2003 02:32   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Indeed it does, great program!!

Thanks..
gadgetboyDUP

Posts: 2
Registered: 14-Apr-2003
Re: Proccess your own template files
Posted: 08-Jan-2004 09:47   in response to: Graeme in response to: Graeme
  Click to reply to this thread Reply
I'm very interested of this function is there someone who have implemented this in there skin and like to share there skin so i can se it in action ?

/Best Regards
Karl
kaya

Posts: 72
Registered: 19-Jun-2003
Re: Proccess your own template files
Posted: 13-Jan-2004 00:33   in response to: gadgetboyDUP in response to: gadgetboyDUP
  Click to reply to this thread Reply
I use such technic in my skin PositionMap. But I use my own hashmap with my own variables which I pass to the engine because I don't need all JAlbum variables in the new page.

Take a look at the end of index.htt
Download link:
http://jrepository.engblom.org/GetSkin.asp?GUID=CCC210E2-D891-4E29-94DD-6A57C60191EE
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums