Hi all,

Still trying to learn all the in's and out's of C::A. I'm curious about
handling situations where I have common operations that must be applied to
all modes upon exiting. Example:

I load a unique .tmpl files and assign values to parameters in run modes.
But before outputing, I want to assign some values common to all of .tmpls.
cgiapp_postrun doesn't always work because it runs after each mode, and I
only want it to run after all modes are finished (forwarding). I tried it
teardown, but I lose the $common values somewhere before I get there.

I wish there was something like "cgiapp_lastrun" that would come only after
the last mode for the instance was run, and before teardown.

Anyway, here's my scenario:

my ($template);

sub cgiapp_init {
   #set paths
}

sub setup {
   my $self = shift;
   $self->mode_param('rm');
   $self->run_modes(
     'mode1' => 'mode_1',
     'mode2' => 'mode_2',
     'mode3  => 'mode_3',
   )
}

sub teardown {
   $template->param(graphic => $common->{'header_graphic'});
}

sub cgiapp_prerun {
   #get $common values from database
}

sub mode_1 {
   #do stuff
   $template = $self->load_tmpl('users.tmpl');
   $template->param(users  => $users);
   return $template->output;
}

sub mode_2 {
   #do stuff
   $template = $self->load_tmpl('products.tmpl');
   $template->param(products  => $products);
   return $template->output;
}

sub mode_3 {
   #do stuff
   $self->forward('mode1');
}

Brad



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to