Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: HTML::Template, CGI:Application and design methodologies

by Trimbach (Curate)
on Feb 11, 2004 at 01:04 UTC ( #328094=note: print w/ replies, xml ) Need Help??


in reply to HTML::Template, CGI:Application and design methodologies

I would strongly consider templatize-ing the entire page, top, left, and main. One of the reasons you template in the first place is to separate your program logic from your design, and to consolidate your designs for easy updating and re-use. Assigning separate "modes" to your top and left menu bars sounds awfully complicated to me. If the top and left sections are static, why not just TMPL_INCLUDE it, and if there are small changes (along the lines of "you are here" site navigation and such) that stuff's a piece of cake by throwing in some TMPL_VAR's or by judicious use of TMPL_IF in your template. If the top and side REALLY change in bizarre and complex ways for each mode, that's a clue that you should be using different templates. No one says you have to use only one template for every page in your site. :-) Trying to manage different parts of the same template through "modes" sounds like a recipe for spaghetti-code to me.

Gary Blackburn
Trained Killer


Comment on Re: HTML::Template, CGI:Application and design methodologies
Select or Download Code
Re: Re: HTML::Template, CGI:Application and design methodologies
by rchiav (Deacon) on Feb 11, 2004 at 04:22 UTC
    My concern with having everything in essentially one template (rather one template that includes other templates that include other templates) is that it might overcomplicate the data structure. In the small app I'm currently working on, I create 3 or 4 template objects and print each of their outputs. Each invocation of these templates is presenting data from unrelated queries.

    I guess I'm just going to have to try it and see how well it works.

      In the small app I'm currently working on, I create 3 or 4 template objects and print each of their outputs. Each invocation of these templates is presenting data from unrelated queries.

      This is just a suggestion on how this might be managed (and simplified) with one template object:

      sub some_mode { my $tmpl_object = $self->load_tmpl('my_tmpl.html'); $tmpl_object->param( param1 => 'foo' param2 => 'bar', param3 => 'baz'); # Poke the data for the top part of the page into the $tmpl_object get_top($tmpl_object); # Ditto for the left side of the page get_left($tmpl_object); # Display the entire templated page return $tmpl_object->output; }

      Of course you can add parameters to get_top() and get_left() to fine tune their output on a mode-by-mode basis, but by passing around one template object at a time things may become much simpler than having your program eat its tail calling one recursive mode within a mode within a mode after another.

      Gary Blackburn
      Trained Killer

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://328094]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-08-29 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (277 votes), past polls