[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Re: Exit strategies from C::A


On 12/28/05, suppressed <suppressed> wrote:
> I tried this, but to no avail:

I'm not 100% sure what you are trying to accomplish, but I am guessing
that you want to provide some parameters to all of your runmode
templates.  If that isn't what you want, maybe reword your question.

> my $template;

Why is this defined in the global scope?  That is often a sign of a problem.

> sub setup {
>    #do normal setup and run mode1
>   $self->param('graphic','header.gif');
> }
>
> sub teardown {
>    my $self = shift;
>    my $graphic = $self->param('graphic'); # <-$graphic has a value here!
>    $template->param(graphic => $graphic); # <-but doesn't get passed to
> template here
> }

The teardown phase happens after the page has already been sent to the
browser.  So doing anything with the template will not do anything
useful.

> sub mode1 {
>    $template = $self->load_tmpl('users.tmpl');
>    return $template->output;
> }

The easiest way to add template parameters to all of your templates is
to override the load_tmpl method.

sub load_tmpl {
  my $self = shift;
  # Call the real load_tmpl to get a template object
  my $template = $self->SUPER::load_tmpl(@_);
  # add a parameter
  $template->param(graphic => 'header.gif');
  return $template;
}

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.