Have a look at help on "filters" in the HTML::Template documentation. 
They usually come very handy for this type of stuff... 



On Mon, 2004-03-29 at 14:32, Bill Nixon wrote:
> How about using another instance of HTML::Template within your code to generate the 
> upselling HTML text and assign the Template
> output to a TMPL_VAR.
> 
> Something like:
> 
> # generate the upsell HTML
> my $upsell_template = HTML::Template->new(filename => 'test.tmpl');
> ...
> my $upsell_html = $upsell_template->output;
> 
> # handle the main template
> my $main_template = HTML::Template->new ...
> ...
> # include the upsell HTML as a TMPL_VAR
> $template->param(UPSELL_HTML => $upsell_html);
> 
> Then, in your main HTML file, just use a normal <TMPL_VAR name="UPSELL_HTML"> to 
> include the HTML where you want it.
> 
> ----- Original Message ----- 
> From: "Adrian Grigore" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, March 28, 2004 9:04 AM
> Subject: [htmltmpl] TMPL_INCLUDE with variable name?
> 
> 
> > Hi,
> >
> > I would like to create a template representing a sales checkout page which
> > is supposed to have different upselling items on the bottom, depending
> > which items are currently in the shopping basket. I would like to include
> > the HTML tag to the upselling item with TMPL_INCLUDE, but the problem is
> > that the name of the template that should be included is dynamic, so I
> > cannot write that as fixed string into the shopping basked template.
> >
> > The problem description above is probably too confusing, so here's an
> > example of what I am trying to do. I have this template which the contents
> > of the user's shopping basket plus an upselling item:
> >
> > some code for displaying shopping cart....
> > <!-- now include the template that includes the upselling item -->
> > <TMPL_INCLUDE NAME="myupsellingitem1.tmpl">
> > some more code for the page footer.
> >
> > Now, this works fine if I have only one upselling item. But If I have 2 of
> > them and only the perl script knows which one should be displayed I would
> > need I TMPL_INCLUDE that works with a name refers to the name of a TMPL_VAR
> > of the same context. I would need something like this:
> >
> > some code for displaying shopping cart....
> > <!-- now include the template that includes the upselling item -->
> > <TMPL_INCLUDE NAME=UPSELLING_TEMPLATE_FILENAME>
> > some more code for the page footer.
> >
> > and of course I would need to have something like
> > $Template->param(UPSELLING_TEMPLATE_FILENAME => 'myupsellingitem1.tmpl');
> > in my template.
> >
> > Unfortunately this is currently not possible in HTML::Template. I could
> > think of loading the template via HTTP and using server side includes or
> > php to do the job, but that would be an ugly solution. It would also be
> > possible to "filter" the output of one template and use it as input for the
> > next, but that would be quite messy too. Is there any clean way to do this?
> >
> > Thanks,
> >
> > Adrian Grigore
> >
> > --
> > Adrian Grigore
> > [EMAIL PROTECTED]
> > Lobstersoft - Fun Brain-Bending Games For All Ages
> > http://www.lobstersoft.com
> > Member of the Association of Shareware Professionals
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: IBM Linux Tutorials
> > Free Linux tutorial presented by Daniel Robbins, President and CEO of
> > GenToo technologies. Learn everything from fundamentals to system
> > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> > _______________________________________________
> > Html-template-users mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/html-template-users
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Html-template-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to