sub navbar_callback { my ($self, $ht_params, $tmpl_params, $tmpl_file) = @_; if( $tmpl_file eq 'master.tmpl' ) { # load your variables my %navbar_params = $self->navbar_params; $tmpl_params->{$_} = $navbar_params{$_} foreach keys %navbar_params; # alternatively, you could also load a separate template for the navbar, and # pass it on to the master as a tmpl_var. Note that the if() clause protects you # from an infinite loop # $tmpl_params->{navbar} = $self->navbar_template; } } #### sub setup { my $self = shift; $self->add_callback( 'load_tmpl' => 'navbar_callback' ); } #### sub cgiapp_postrun { my ( $self, $outputref ) = @_; # the following conditionals protect us from trampling on # 'redirect' runmodes, or non-html output. if( $self->header_type eq 'header' ) { my %props = $self->header_props; if( !exists( $props{'-type'} ) or $props{'-type'} eq 'text/html' ) { my $t = $self->load_tmpl('master.tmpl'); $t->param( runmode_content => $$outputref ); $t->param( navbar_content => $self->navbar_template ); $$outputref = $t->output; } } }