Hello,
See below for an answer to your question.
--- Dirk Weßner <suppressed> wrote:
> Hello,
>
> I want to have an application howing several screens,
> each screen shows the same navigation/menu bar and
> some screen-specific content.
>
> So I have one template containing my menu bar, and several
> other templates, one for each screen, each <TMPL_INCLUDING>
> my "menu_bar.tmpl".
>
> So far, so good. But what is the best practice to avoid writing
> the code for populating <TMPL_VARS> in "menu_bar.tmpl"
> in every run mode?
>
Create a method called "showForm" that is called as the final step in
each run mode and put your menu UI configuration stuff there. Do your
context specific stuff in each individual run mode.
I have used this approach with gooed results.
sub runmode1
{
...
# your runmode1 logic goes here
...
return $self->showForm( $template );
}
sub showForm {
...
$tmpl->param(par1 => $foo);
$self->populate_menu( $q, $tmpl );
return tmpl->output;
}
The above pseudo-code assumes that you will be passing
an HTML::Template instance to "showForm".
cheers,
-john
> Maybe like this?
>
> sub runmode1
> {
> ...
> $tmpl1->param(par1 => $foo);
>
> $self->populate_menu( $q, $tmpl1 );
>
> ...
> return $tmpl1->output();
> }
> sub runmode2
> {
> ...
> $tmpl2->param(par2 => $bar);
>
> $self->populate_menu( $q, $tmpl2 );
>
> ...
> return $tmpl2->output();
> }
> sub populate_menu
> {
> ...
> my $q = shift;
> my $tmpl = shift;
>
> #Get values for <TMPL_VARS> in menu_bar.tmpl
> #somehow (DB-Access, calculate, etc...)
>
> $tmpl->param(menu_var => $xyz);
> ...
> }
>
>
> Other ideas?
>
> Thank you in advance,
>
> --Dirk
>
> "In a world without fences,
> who needs Gates?"
>
> --
> "In a world without fences,
> who needs Gates?"
>
> +++ GMX - Mail, Messaging & more http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
>
>
> ---------------------------------------------------------------------
> Web Archive: http://www.mail-archive.com/suppressed/
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
>
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
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.