|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
proposal for new cgiapp hook: loaded_html_tmplHere's a new proposal for solving the multiple template parsing problem when die_on_bad_params is enabled. Add another callback to CGI::Application: loaded_html_tmpl This gets called with the newly created template object before it gets returned to the user. CAP::AnyTemplate and CAP::TT would not call this hook. Plugins wishing to automatically pass variables to templates would do the following: * hook the 'load_tmpl' callback - if html_tmpl_class isa 'HTML::Template' then return. - Otherwise, add parameters to $tmpl_params * hook the 'loaded_html_template' callback - return unless html_tmpl_class isa 'HTML::Template' - check $ht_params for die_on_bad_params (default to 1) - if die_on_bad_params is enabled, use HTML::Template's query method to determine whether or not it is safe to add the parameter. - if it is safe, add the parameter via $tmpl->param(); I don't know how many people use die_on_bad_params, so I don't know how worth it it is to modify the core. However, this hook would improve performance for users of die_on_bad_params when using plugins that automatically add template values, and it would greatly simplify the code required in each of these plugins. Michael -- Michael Graham <magog@...> ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: proposal for new cgiapp hook: loaded_html_tmplMichael -- > Here's a new proposal for solving the multiple template parsing problem > when die_on_bad_params is enabled. Add another callback to > CGI::Application: > > loaded_html_tmpl > > This gets called with the newly created template object before it gets > returned to the user. CAP::AnyTemplate and CAP::TT would not call this > hook. > > Plugins wishing to automatically pass variables to templates would do > the following: > > * hook the 'load_tmpl' callback > - if html_tmpl_class isa 'HTML::Template' then return. > - Otherwise, add parameters to $tmpl_params > > * hook the 'loaded_html_template' callback > - return unless html_tmpl_class isa 'HTML::Template' > - check $ht_params for die_on_bad_params (default to 1) > - if die_on_bad_params is enabled, use HTML::Template's query method > to determine whether or not it is safe to add the parameter. > - if it is safe, add the parameter via $tmpl->param(); > > I don't know how many people use die_on_bad_params, so I don't > know how worth it it is to modify the core. > > However, this hook would improve performance for users of > die_on_bad_params when using plugins that automatically add > template values, and it would greatly simplify the code required in > each of these plugins. How would your propose to deal with the "HTML::Template-like" modules that do not pass the "isa HTML::Template" test but are generally compatible? Could we test for the features we need instead of the classes they come from? Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer mark@... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: proposal for new cgiapp hook: loaded_html_tmplHi Mark! > How would your propose to deal with the "HTML::Template-like" modules > that do not pass the "isa HTML::Template" test but are generally > compatible? > > Could we test for the features we need instead of the classes they > come from? Right, of course - that makes much more sense. Maybe we could use '$class->can("query")' instead of '$class->isa("HTML::Template")'. I'm thinking that each plugin that wanted to pass template parameters would do something like this: ## hooked via load_tmpl sub my_load_tmpl_callback { my ($c, $ht_params, $tmpl_params, $tmpl_file) = @_; my $template_class = $c->html_tmpl_class; eval "require $template_class;"; # for HTML::Template and compatible templating # systems, don't add params here, add them in # the loaded_html_template callback instead # detect HTML::Template - compatibility by presence # of a 'query' method return if eval { $template_class->can('query') }; $tmpl_params->{'my_param'} = 'some_value'; } ## hooked via loaded_html_tmpl sub my_html_template_loaded_callback { my ($c, $ht_params, $tmpl_params, $tmpl_file, $tmpl_obj) = @_; my $template_class = $c->html_tmpl_class; eval "require $template_class;"; # skip if not HTML::Template or compatible, # because we should have already added params under # the load_tmpl callback # detect HTML::Template - compatibility by presence # of a 'query' method return unless eval { $template_class->can('query') }; if (!exists $ht_params->{'die_on_bad_params'} or $ht_params->{'die_on_bad_params'}) { return unless $tmpl_obj->query( name => 'my_param', ); } $tmpl_obj->param('my_param' => 'some_value'); } Problems I see with this approach: 1) html_tmpl_class being used contrary to its original purpose. Returning 'Petal' or 'Template' or 'Template::Toolkit' from this attribute seems weird, since it's named 'html_tmpl...' and none of these other templating systems are related to HTML::Template at all. Maybe this isn't a big deal. At the very least, to support a mix of templating systems, plugins like CAP::TT and CAP::AnyTemplate should probably only set this attribute for the duration of the 'load_tmpl' hook, e.g. my $saved_class = $c->html_tmpl_class; $c->html_tmpl_class('Template'); $self->call_hook('load_tmpl', ... ); $c->html_tmpl_class($saved_class); 2) What happens if another templating system provides a 'query' method that does something completely different from what HTML::Template's 'query' does? 3) Plugin code complexity. While this approach does reduce the code that plugins have to include, it's still a lot of code to write (and test) just to add a template parameter. It's also pretty tricky and fragile for a standard API. Maybe it could be wrapped up into its own "CAP::AddTemplateParams" plugin with a simpler API? A plugin that wanted to add template parameters would do something like this: use CGI::Application::Plugin::AddTemplateParams; sub import { my $caller = scalar(caller); if ($caller->can('add_callback')) { $caller->add_callback( 'add_template_params' => \&_add_tmpl_parms ); } } ## hooked via add_template_params sub _add_tmpl_parms { my ($c, $tmpl_params) = @_; $tmpl_params->{'my_param'} = 'some_value'; } Michael -- Michael Graham <magog@...> ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Adding a div of fixed content to evey page. Possible?Hi,
Is it possible to add the output of a template to every page/run-mode without going through assigning it to a template->param in each run-mode? I am aware of using cgi-postrun to wrap the output of a run-mode, but it seems not possible to *insert* a div of content in an arbitraty (but fixed position) using this trick. Or is it? I would also like to avoid another template processor (like HTML::Mason or Text::Template) to do this if there is an easier way. Thanks for your attention Gurunandan ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?In postrun you can populate a variable with a subroutine call and then
substitute that variable anywhere in your template, or even insert it into your runmode output if desired. Is that what you are looking for, or am I way off base? Gurunandan R. Bhat wrote: > Hi, > > Is it possible to add the output of a template to every page/run-mode > without going through assigning it to a template->param in each > run-mode? > > I am aware of using cgi-postrun to wrap the output of a run-mode, but it > seems not possible to *insert* a div of content in an arbitraty (but > fixed position) using this trick. Or is it? > > I would also like to avoid another template processor (like HTML::Mason > or Text::Template) to do this if there is an easier way. > > Thanks for your attention > Gurunandan > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?You could use a callback, assigning a function to the load_tmpl hook and
then within that function, modify/insert your div of content into the template parameters. HTH, Jason Gurunandan R. Bhat wrote: > Hi, > > Is it possible to add the output of a template to every page/run-mode > without going through assigning it to a template->param in each > run-mode? > > I am aware of using cgi-postrun to wrap the output of a run-mode, but it > seems not possible to *insert* a div of content in an arbitraty (but > fixed position) using this trick. Or is it? > > I would also like to avoid another template processor (like HTML::Mason > or Text::Template) to do this if there is an easier way. > > Thanks for your attention > Gurunandan > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?Yes thats what I want to do. To be specific, I want to insert a login
form on every page or a logged-in status depending on whether $app->authen->username is defined or not (I am using CAP-Authentication). But when I am in post-run, HTML::Template has done its job and no template variables are available any more - unless I use another templating system that will process the plain text available in postrun. In the light of this I am not sure how your suggestion will work. Unless I haven't really understood what is available to postrun. REgards Gurunandan On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: > In postrun you can populate a variable with a subroutine call and then > substitute that variable anywhere in your template, or even insert it > into your runmode output if desired. > > Is that what you are looking for, or am I way off base? > > > > Gurunandan R. Bhat wrote: > > Hi, > > > > Is it possible to add the output of a template to every page/run-mode > > without going through assigning it to a template->param in each > > run-mode? > > > > I am aware of using cgi-postrun to wrap the output of a run-mode, but it > > seems not possible to *insert* a div of content in an arbitraty (but > > fixed position) using this trick. Or is it? > > > > I would also like to avoid another template processor (like HTML::Mason > > or Text::Template) to do this if there is an easier way. > > > > Thanks for your attention > > Gurunandan > > > > > > ##### CGI::Application community mailing list ################ > > ## ## > > ## To unsubscribe, or change your message delivery options, ## > > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > > ## ## > > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > > ## Wiki: http://cgiapp.erlbaum.net/ ## > > ## ## > > ################################################################ > > > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?Thanks Jason. This seems to be the most appropriate solution in my
situation. Amazing how extensible CGI-App is! Regards Gurunandan On Fri, 2009-10-30 at 14:44 -0400, Jason Purdy wrote: > You could use a callback, assigning a function to the load_tmpl hook and > then within that function, modify/insert your div of content into the > template parameters. > > HTH, > > Jason > > Gurunandan R. Bhat wrote: > > Hi, > > > > Is it possible to add the output of a template to every page/run-mode > > without going through assigning it to a template->param in each > > run-mode? > > > > I am aware of using cgi-postrun to wrap the output of a run-mode, but it > > seems not possible to *insert* a div of content in an arbitraty (but > > fixed position) using this trick. Or is it? > > > > I would also like to avoid another template processor (like HTML::Mason > > or Text::Template) to do this if there is an easier way. > > > > Thanks for your attention > > Gurunandan > > > > > > ##### CGI::Application community mailing list ################ > > ## ## > > ## To unsubscribe, or change your message delivery options, ## > > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > > ## ## > > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > > ## Wiki: http://cgiapp.erlbaum.net/ ## > > ## ## > > ################################################################ > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
|
|
|
Re: Adding a div of fixed content to evey page. Possible?On Fri, Oct 30, 2009 at 11:47 AM, Gurunandan R. Bhat
<guru@...> wrote: > I want to insert a login > form on every page or a logged-in status depending on whether > $app->authen->username is defined or not (I am using > CAP-Authentication). Why wouldn't this just be an "include" file, included into all your HTML::Templates, and the include containing some TMPL_IF logic to control whether the login form (or logged-in status) should be displayed? Mark ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?First, Thanks for responding.
Are you suggesting that I populate a template variable with another HTML::Template-tagged piece and then populate that piece in postrun? If yes, wouldn't I have to do that in every runmode - something that I wanted to avoid? Would it not be better if I called $app->param(LOGINFORM => 'Content of Form') (as opposed to $tpl->param()) in prerun and have it set for every runmode without doing so explicitly in each runmode? I am not getting it. My bad, obviously On Fri, 2009-10-30 at 14:55 -0400, Brad Van Sickle wrote: > > You can initialize and populate your template in postrun as well. > > The way I do it is I typically load the framework of the page using > HTML::Template in postrun, and then insert the output of my runmode into > the template where required. > > If your runmode output is complex enough to require being templated > itself, there isn't anything stopping you from using HTML::Template > within the runmode to format the output and then inserting the output of > that template into the overall template in postrun. > > You can even move postrun up into a superclass to centralize all of this > content and keep a coherent look on your site. > > At least that's the easiest and most flexible solution I found when I > was faced with a similar problem... > > > > > > > > > > Gurunandan R. Bhat wrote: > >> Yes thats what I want to do. To be specific, I want to insert a login > >> form on every page or a logged-in status depending on whether > >> $app->authen->username is defined or not (I am using > >> CAP-Authentication). > >> > >> But when I am in post-run, HTML::Template has done its job and no > >> template variables are available any more - unless I use another > >> templating system that will process the plain text available in postrun. > >> In the light of this I am not sure how your suggestion will work. > >> > >> Unless I haven't really understood what is available to postrun. > >> > >> REgards > >> Gurunandan > >> > >> > >> On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: > >> > >> > >>> In postrun you can populate a variable with a subroutine call and then > >>> substitute that variable anywhere in your template, or even insert it > >>> into your runmode output if desired. > >>> > >>> Is that what you are looking for, or am I way off base? > >>> > >>> > >>> > >>> Gurunandan R. Bhat wrote: > >>> > >>>> Hi, > >>>> > >>>> Is it possible to add the output of a template to every page/run-mode > >>>> without going through assigning it to a template->param in each > >>>> run-mode? > >>>> > >>>> I am aware of using cgi-postrun to wrap the output of a run-mode, but it > >>>> seems not possible to *insert* a div of content in an arbitraty (but > >>>> fixed position) using this trick. Or is it? > >>>> > >>>> I would also like to avoid another template processor (like HTML::Mason > >>>> or Text::Template) to do this if there is an easier way. > >>>> > >>>> Thanks for your attention > >>>> Gurunandan > >>>> > >>>> > >>>> ##### CGI::Application community mailing list ################ > >>>> ## ## > >>>> ## To unsubscribe, or change your message delivery options, ## > >>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>> ## ## > >>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>> ## ## > >>>> ################################################################ > >>>> > >>>> > >>>> > >>> ##### CGI::Application community mailing list ################ > >>> ## ## > >>> ## To unsubscribe, or change your message delivery options, ## > >>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>> ## ## > >>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>> ## ## > >>> ################################################################ > >>> > >>> > >> > >> > >> > >> ##### CGI::Application community mailing list ################ > >> ## ## > >> ## To unsubscribe, or change your message delivery options, ## > >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >> ## ## > >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >> ## Wiki: http://cgiapp.erlbaum.net/ ## > >> ## ## > >> ################################################################ > >> > >> > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?I wanted to avoid, including the file, and then assigning the params (Logged in/Not loggedin, Last login, etc) in each and every run mode when their values are universal across the application and have nothing to do with the logic of each run mode. On Fri, 2009-10-30 at 12:13 -0700, Mark Fuller wrote: > On Fri, Oct 30, 2009 at 11:47 AM, Gurunandan R. Bhat > <guru@...> wrote: > > I want to insert a login > > form on every page or a logged-in status depending on whether > > $app->authen->username is defined or not (I am using > > CAP-Authentication). > > Why wouldn't this just be an "include" file, included into all your > HTML::Templates, and the include containing some TMPL_IF logic to > control whether the login form (or logged-in status) should be > displayed? > > Mark > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?My postrun sits in a superclass, so I have one "postrun" that serves the entire application. From within that postrun I do something similar to the following: postrun { #load page framework template my $template = $self->load_tmpl( $TemplateFile, cache => 1, die_on_bad_params =>0, ); #get "widget" content my $widget1=&Get_Widget1; #return html to insert into widget1 my $widget2=$Get_Widget2; #return html to insert into widget2 # Fill in template parameters $template->param( WIDGET1 => $widget1, WIDGET2 => $widget2, RUNMODE_CONTENT => $$output_ref, ); #overwrite the output with the output of the template $$output_ref= $template->output; } Then in my runmode: runmode { ################ #get output ################ #load rumode template that has only the html for this section, not the full page my $template = $self->load_tmpl( $RMTemplateFile, cache => 1, die_on_bad_params =>0, ); # Fill in template parameters $template->param( WHATEVER1 => $var1 WHATEVER2 => $var2 ); #return formatted runmode content content to postrun return $template->output; } This allows me to control the format of my runmode output, and then stick that formatted content into an overall page template. Since I have postrun in a superclass, and it services my entire application, I only have one piece of code to track. I'm sure this isn't the only option, (in fact the other responses seem like they would work as well) but for the projects I've used this method on I've been really pleased with the combination of flexibility and centralized code management it provides. Gurunandan R. Bhat wrote: > First, Thanks for responding. > > Are you suggesting that I populate a template variable with another > HTML::Template-tagged piece and then populate that piece in postrun? If > yes, wouldn't I have to do that in every runmode - something that I > wanted to avoid? > > Would it not be better if I called $app->param(LOGINFORM => 'Content of > Form') (as opposed to $tpl->param()) in prerun and have it set for every > runmode without doing so explicitly in each runmode? > > I am not getting it. My bad, obviously > > > On Fri, 2009-10-30 at 14:55 -0400, Brad Van Sickle wrote: > >> You can initialize and populate your template in postrun as well. >> >> The way I do it is I typically load the framework of the page using >> HTML::Template in postrun, and then insert the output of my runmode into >> the template where required. >> >> If your runmode output is complex enough to require being templated >> itself, there isn't anything stopping you from using HTML::Template >> within the runmode to format the output and then inserting the output of >> that template into the overall template in postrun. >> >> You can even move postrun up into a superclass to centralize all of this >> content and keep a coherent look on your site. >> >> At least that's the easiest and most flexible solution I found when I >> was faced with a similar problem... >> >> >> >>> >>> Gurunandan R. Bhat wrote: >>> >>>> Yes thats what I want to do. To be specific, I want to insert a login >>>> form on every page or a logged-in status depending on whether >>>> $app->authen->username is defined or not (I am using >>>> CAP-Authentication). >>>> >>>> But when I am in post-run, HTML::Template has done its job and no >>>> template variables are available any more - unless I use another >>>> templating system that will process the plain text available in postrun. >>>> In the light of this I am not sure how your suggestion will work. >>>> >>>> Unless I haven't really understood what is available to postrun. >>>> >>>> REgards >>>> Gurunandan >>>> >>>> >>>> On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: >>>> >>>> >>>> >>>>> In postrun you can populate a variable with a subroutine call and then >>>>> substitute that variable anywhere in your template, or even insert it >>>>> into your runmode output if desired. >>>>> >>>>> Is that what you are looking for, or am I way off base? >>>>> >>>>> >>>>> >>>>> Gurunandan R. Bhat wrote: >>>>> >>>>> >>>>>> Hi, >>>>>> >>>>>> Is it possible to add the output of a template to every page/run-mode >>>>>> without going through assigning it to a template->param in each >>>>>> run-mode? >>>>>> >>>>>> I am aware of using cgi-postrun to wrap the output of a run-mode, but it >>>>>> seems not possible to *insert* a div of content in an arbitraty (but >>>>>> fixed position) using this trick. Or is it? >>>>>> >>>>>> I would also like to avoid another template processor (like HTML::Mason >>>>>> or Text::Template) to do this if there is an easier way. >>>>>> >>>>>> Thanks for your attention >>>>>> Gurunandan >>>>>> >>>>>> >>>>>> ##### CGI::Application community mailing list ################ >>>>>> ## ## >>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>> ## ## >>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>> ## ## >>>>>> ################################################################ >>>>>> >>>>>> >>>>>> >>>>>> >>>>> ##### CGI::Application community mailing list ################ >>>>> ## ## >>>>> ## To unsubscribe, or change your message delivery options, ## >>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>> ## ## >>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>> ## ## >>>>> ################################################################ >>>>> >>>>> >>>>> >>>> >>>> ##### CGI::Application community mailing list ################ >>>> ## ## >>>> ## To unsubscribe, or change your message delivery options, ## >>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>> ## ## >>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>> ## ## >>>> ################################################################ >>>> >>>> >>>> >> ##### CGI::Application community mailing list ################ >> ## ## >> ## To unsubscribe, or change your message delivery options, ## >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >> ## ## >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >> ## Wiki: http://cgiapp.erlbaum.net/ ## >> ## ## >> ################################################################ >> >> > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?Assigning those variables is the perfect thing to do in (again) postrun
when it is implemented in a superclass. Gurunandan R. Bhat wrote: > I wanted to avoid, including the file, and then assigning the params > (Logged in/Not loggedin, Last login, etc) in each and every run mode > when their values are universal across the application and have nothing > to do with the logic of each run mode. > > > > > On Fri, 2009-10-30 at 12:13 -0700, Mark Fuller wrote: > >> On Fri, Oct 30, 2009 at 11:47 AM, Gurunandan R. Bhat >> <guru@...> wrote: >> >>> I want to insert a login >>> form on every page or a logged-in status depending on whether >>> $app->authen->username is defined or not (I am using >>> CAP-Authentication). >>> >> Why wouldn't this just be an "include" file, included into all your >> HTML::Templates, and the include containing some TMPL_IF logic to >> control whether the login form (or logged-in status) should be >> displayed? >> >> Mark >> >> ##### CGI::Application community mailing list ################ >> ## ## >> ## To unsubscribe, or change your message delivery options, ## >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >> ## ## >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >> ## Wiki: http://cgiapp.erlbaum.net/ ## >> ## ## >> ################################################################ >> >> > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?Now I get it! Thanks for staying with me.
However my point is that I cannot do this: > # Fill in template parameters > $template->param( > WIDGET1 => $widget1, > WIDGET2 => $widget2, > RUNMODE_CONTENT => $$output_ref, > ); for any layout - specifically where the design (HTML) of the page is such that it does not allow cleanly separating the widgets from the surrounding content. Unfortunately I have a layout where the business output from the runmodes cannot be cleanly separated from the fixed content (in my case a login form). However in situations where such a separation in possible, yours is an excellent and preferred solution, So Thanks On Fri, 2009-10-30 at 15:25 -0400, Brad Van Sickle wrote: > My postrun sits in a superclass, so I have one "postrun" that serves the > entire application. > > From within that postrun I do something similar to the following: > > postrun > { > #load page framework template > my $template = $self->load_tmpl( > $TemplateFile, > cache => 1, > die_on_bad_params =>0, > ); > > #get "widget" content > my $widget1=&Get_Widget1; #return html to insert into widget1 > my $widget2=$Get_Widget2; #return html to insert into widget2 > > # Fill in template parameters > $template->param( > WIDGET1 => $widget1, > WIDGET2 => $widget2, > RUNMODE_CONTENT => $$output_ref, > ); > > #overwrite the output with the output of the template > $$output_ref= $template->output; > } > > Then in my runmode: > > runmode > { > ################ > #get output > ################ > > #load rumode template that has only the html for this section, not > the full page > my $template = $self->load_tmpl( > $RMTemplateFile, > cache => 1, > die_on_bad_params =>0, > ); > > # Fill in template parameters > $template->param( > WHATEVER1 => $var1 > WHATEVER2 => $var2 > ); > > #return formatted runmode content content to postrun > return $template->output; > } > > This allows me to control the format of my runmode output, and then > stick that formatted content into an overall page template. Since I > have postrun in a superclass, and it services my entire application, I > only have one piece of code to track. > > I'm sure this isn't the only option, (in fact the other responses seem > like they would work as well) but for the projects I've used this method > on I've been really pleased with the combination of flexibility and > centralized code management it provides. > > > > Gurunandan R. Bhat wrote: > > First, Thanks for responding. > > > > Are you suggesting that I populate a template variable with another > > HTML::Template-tagged piece and then populate that piece in postrun? If > > yes, wouldn't I have to do that in every runmode - something that I > > wanted to avoid? > > > > Would it not be better if I called $app->param(LOGINFORM => 'Content of > > Form') (as opposed to $tpl->param()) in prerun and have it set for every > > runmode without doing so explicitly in each runmode? > > > > I am not getting it. My bad, obviously > > > > > > On Fri, 2009-10-30 at 14:55 -0400, Brad Van Sickle wrote: > > > >> You can initialize and populate your template in postrun as well. > >> > >> The way I do it is I typically load the framework of the page using > >> HTML::Template in postrun, and then insert the output of my runmode into > >> the template where required. > >> > >> If your runmode output is complex enough to require being templated > >> itself, there isn't anything stopping you from using HTML::Template > >> within the runmode to format the output and then inserting the output of > >> that template into the overall template in postrun. > >> > >> You can even move postrun up into a superclass to centralize all of this > >> content and keep a coherent look on your site. > >> > >> At least that's the easiest and most flexible solution I found when I > >> was faced with a similar problem... > >> > >> > >> > >>> > >>> Gurunandan R. Bhat wrote: > >>> > >>>> Yes thats what I want to do. To be specific, I want to insert a login > >>>> form on every page or a logged-in status depending on whether > >>>> $app->authen->username is defined or not (I am using > >>>> CAP-Authentication). > >>>> > >>>> But when I am in post-run, HTML::Template has done its job and no > >>>> template variables are available any more - unless I use another > >>>> templating system that will process the plain text available in postrun. > >>>> In the light of this I am not sure how your suggestion will work. > >>>> > >>>> Unless I haven't really understood what is available to postrun. > >>>> > >>>> REgards > >>>> Gurunandan > >>>> > >>>> > >>>> On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: > >>>> > >>>> > >>>> > >>>>> In postrun you can populate a variable with a subroutine call and then > >>>>> substitute that variable anywhere in your template, or even insert it > >>>>> into your runmode output if desired. > >>>>> > >>>>> Is that what you are looking for, or am I way off base? > >>>>> > >>>>> > >>>>> > >>>>> Gurunandan R. Bhat wrote: > >>>>> > >>>>> > >>>>>> Hi, > >>>>>> > >>>>>> Is it possible to add the output of a template to every page/run-mode > >>>>>> without going through assigning it to a template->param in each > >>>>>> run-mode? > >>>>>> > >>>>>> I am aware of using cgi-postrun to wrap the output of a run-mode, but it > >>>>>> seems not possible to *insert* a div of content in an arbitraty (but > >>>>>> fixed position) using this trick. Or is it? > >>>>>> > >>>>>> I would also like to avoid another template processor (like HTML::Mason > >>>>>> or Text::Template) to do this if there is an easier way. > >>>>>> > >>>>>> Thanks for your attention > >>>>>> Gurunandan > >>>>>> > >>>>>> > >>>>>> ##### CGI::Application community mailing list ################ > >>>>>> ## ## > >>>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>>> ## ## > >>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>>> ## ## > >>>>>> ################################################################ > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>> ##### CGI::Application community mailing list ################ > >>>>> ## ## > >>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>> ## ## > >>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>> ## ## > >>>>> ################################################################ > >>>>> > >>>>> > >>>>> > >>>> > >>>> ##### CGI::Application community mailing list ################ > >>>> ## ## > >>>> ## To unsubscribe, or change your message delivery options, ## > >>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>> ## ## > >>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>> ## ## > >>>> ################################################################ > >>>> > >>>> > >>>> > >> ##### CGI::Application community mailing list ################ > >> ## ## > >> ## To unsubscribe, or change your message delivery options, ## > >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >> ## ## > >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >> ## Wiki: http://cgiapp.erlbaum.net/ ## > >> ## ## > >> ################################################################ > >> > >> > > > > > > > > ##### CGI::Application community mailing list ################ > > ## ## > > ## To unsubscribe, or change your message delivery options, ## > > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > > ## ## > > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > > ## Wiki: http://cgiapp.erlbaum.net/ ## > > ## ## > > ################################################################ > > > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?Gurunandan R. Bhat wrote:
> Now I get it! Thanks for staying with me. > However my point is that I cannot do this: > > >> # Fill in template parameters >> $template->param( >> WIDGET1 => $widget1, >> WIDGET2 => $widget2, >> RUNMODE_CONTENT => $$output_ref, >> ); >> > > for any layout - specifically where the design (HTML) of the page is such that it does not allow cleanly separating the widgets from the surrounding content. > Unfortunately I have a layout where the business output from the runmodes cannot be cleanly separated from the fixed content (in my case a login form). > > However in situations where such a separation in possible, yours is an excellent and preferred solution, So Thanks > -Kurt ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
|
|
|
Re: Adding a div of fixed content to evey page. Possible?> Can you do what you want with the "associate" option to your template? > -Kurt > Indeed I can. But I prefer and am looking for a method that I can call in my SuperClass (prerun or postrun) since the content to be "filled-in" is independent of all individual run-modes. Jason's adding a callback to load_tmpl (assuming it can be done in prerun) or using $app->param in prerun seem to be the most promising solutions to what I have to do. I am open to other solutions insofar as they do not require any action in the run-mode itself. Incidentally, using associate has an additional hidden cost: In my pre-run I must populate the $query object with artificial params that have nothing to do with business params Thanks. ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?<div>Banner</div>
<div>Left Column</div> <div> Some Business Content <div>Login Box Here</div> More Business Content </div> On Fri, 2009-10-30 at 16:04 -0400, Brad Van Sickle wrote: > I have a hard time imagining a scenario where you couldn't make it work > with some clever templating, but you certainly know your requirements > better than I do. Perhaps if you could provide me an example of HTML > layout I might have a better idea about what you're talking about? > > Hopefully this is at least useful to you in a future project. > > > > > > > > Gurunandan R. Bhat wrote: > >> Now I get it! Thanks for staying with me. > >> However my point is that I cannot do this: > >> > >> > >>> # Fill in template parameters > >>> $template->param( > >>> WIDGET1 => $widget1, > >>> WIDGET2 => $widget2, > >>> RUNMODE_CONTENT => $$output_ref, > >>> ); > >>> > >> > >> for any layout - specifically where the design (HTML) of the page is such that it does not allow cleanly separating the widgets from the surrounding content. > >> Unfortunately I have a layout where the business output from the runmodes cannot be cleanly separated from the fixed content (in my case a login form). > >> > >> However in situations where such a separation in possible, yours is an excellent and preferred solution, So Thanks > >> > >> > >> > >> On Fri, 2009-10-30 at 15:25 -0400, Brad Van Sickle wrote: > >> > >>> My postrun sits in a superclass, so I have one "postrun" that serves the > >>> entire application. > >>> > >>> From within that postrun I do something similar to the following: > >>> > >>> postrun > >>> { > >>> #load page framework template > >>> my $template = $self->load_tmpl( > >>> $TemplateFile, > >>> cache => 1, > >>> die_on_bad_params =>0, > >>> ); > >>> > >>> #get "widget" content > >>> my $widget1=&Get_Widget1; #return html to insert into widget1 > >>> my $widget2=$Get_Widget2; #return html to insert into widget2 > >>> > >>> # Fill in template parameters > >>> $template->param( > >>> WIDGET1 => $widget1, > >>> WIDGET2 => $widget2, > >>> RUNMODE_CONTENT => $$output_ref, > >>> ); > >>> > >>> #overwrite the output with the output of the template > >>> $$output_ref= $template->output; > >>> } > >>> > >>> Then in my runmode: > >>> > >>> runmode > >>> { > >>> ################ > >>> #get output > >>> ################ > >>> > >>> #load rumode template that has only the html for this section, not > >>> the full page > >>> my $template = $self->load_tmpl( > >>> $RMTemplateFile, > >>> cache => 1, > >>> die_on_bad_params =>0, > >>> ); > >>> > >>> # Fill in template parameters > >>> $template->param( > >>> WHATEVER1 => $var1 > >>> WHATEVER2 => $var2 > >>> ); > >>> > >>> #return formatted runmode content content to postrun > >>> return $template->output; > >>> } > >>> > >>> This allows me to control the format of my runmode output, and then > >>> stick that formatted content into an overall page template. Since I > >>> have postrun in a superclass, and it services my entire application, I > >>> only have one piece of code to track. > >>> > >>> I'm sure this isn't the only option, (in fact the other responses seem > >>> like they would work as well) but for the projects I've used this method > >>> on I've been really pleased with the combination of flexibility and > >>> centralized code management it provides. > >>> > >>> > >>> > >>> Gurunandan R. Bhat wrote: > >>> > >>>> First, Thanks for responding. > >>>> > >>>> Are you suggesting that I populate a template variable with another > >>>> HTML::Template-tagged piece and then populate that piece in postrun? If > >>>> yes, wouldn't I have to do that in every runmode - something that I > >>>> wanted to avoid? > >>>> > >>>> Would it not be better if I called $app->param(LOGINFORM => 'Content of > >>>> Form') (as opposed to $tpl->param()) in prerun and have it set for every > >>>> runmode without doing so explicitly in each runmode? > >>>> > >>>> I am not getting it. My bad, obviously > >>>> > >>>> > >>>> On Fri, 2009-10-30 at 14:55 -0400, Brad Van Sickle wrote: > >>>> > >>>> > >>>>> You can initialize and populate your template in postrun as well. > >>>>> > >>>>> The way I do it is I typically load the framework of the page using > >>>>> HTML::Template in postrun, and then insert the output of my runmode into > >>>>> the template where required. > >>>>> > >>>>> If your runmode output is complex enough to require being templated > >>>>> itself, there isn't anything stopping you from using HTML::Template > >>>>> within the runmode to format the output and then inserting the output of > >>>>> that template into the overall template in postrun. > >>>>> > >>>>> You can even move postrun up into a superclass to centralize all of this > >>>>> content and keep a coherent look on your site. > >>>>> > >>>>> At least that's the easiest and most flexible solution I found when I > >>>>> was faced with a similar problem... > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>> Gurunandan R. Bhat wrote: > >>>>>> > >>>>>> > >>>>>>> Yes thats what I want to do. To be specific, I want to insert a login > >>>>>>> form on every page or a logged-in status depending on whether > >>>>>>> $app->authen->username is defined or not (I am using > >>>>>>> CAP-Authentication). > >>>>>>> > >>>>>>> But when I am in post-run, HTML::Template has done its job and no > >>>>>>> template variables are available any more - unless I use another > >>>>>>> templating system that will process the plain text available in postrun. > >>>>>>> In the light of this I am not sure how your suggestion will work. > >>>>>>> > >>>>>>> Unless I haven't really understood what is available to postrun. > >>>>>>> > >>>>>>> REgards > >>>>>>> Gurunandan > >>>>>>> > >>>>>>> > >>>>>>> On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>>> In postrun you can populate a variable with a subroutine call and then > >>>>>>>> substitute that variable anywhere in your template, or even insert it > >>>>>>>> into your runmode output if desired. > >>>>>>>> > >>>>>>>> Is that what you are looking for, or am I way off base? > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> Gurunandan R. Bhat wrote: > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>>> Hi, > >>>>>>>>> > >>>>>>>>> Is it possible to add the output of a template to every page/run-mode > >>>>>>>>> without going through assigning it to a template->param in each > >>>>>>>>> run-mode? > >>>>>>>>> > >>>>>>>>> I am aware of using cgi-postrun to wrap the output of a run-mode, but it > >>>>>>>>> seems not possible to *insert* a div of content in an arbitraty (but > >>>>>>>>> fixed position) using this trick. Or is it? > >>>>>>>>> > >>>>>>>>> I would also like to avoid another template processor (like HTML::Mason > >>>>>>>>> or Text::Template) to do this if there is an easier way. > >>>>>>>>> > >>>>>>>>> Thanks for your attention > >>>>>>>>> Gurunandan > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> ##### CGI::Application community mailing list ################ > >>>>>>>>> ## ## > >>>>>>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>>>>>> ## ## > >>>>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>>>>>> ## ## > >>>>>>>>> ################################################################ > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>> ##### CGI::Application community mailing list ################ > >>>>>>>> ## ## > >>>>>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>>>>> ## ## > >>>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>>>>> ## ## > >>>>>>>> ################################################################ > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>> ##### CGI::Application community mailing list ################ > >>>>>>> ## ## > >>>>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>>>> ## ## > >>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>>>> ## ## > >>>>>>> ################################################################ > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>> ##### CGI::Application community mailing list ################ > >>>>> ## ## > >>>>> ## To unsubscribe, or change your message delivery options, ## > >>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>>> ## ## > >>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>>> ## ## > >>>>> ################################################################ > >>>>> > >>>>> > >>>>> > >>>> ##### CGI::Application community mailing list ################ > >>>> ## ## > >>>> ## To unsubscribe, or change your message delivery options, ## > >>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>>> ## ## > >>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>>> ## ## > >>>> ################################################################ > >>>> > >>>> > >>>> > >>> ##### CGI::Application community mailing list ################ > >>> ## ## > >>> ## To unsubscribe, or change your message delivery options, ## > >>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >>> ## ## > >>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >>> ## Wiki: http://cgiapp.erlbaum.net/ ## > >>> ## ## > >>> ################################################################ > >>> > >>> > >> > >> > >> > >> ##### CGI::Application community mailing list ################ > >> ## ## > >> ## To unsubscribe, or change your message delivery options, ## > >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > >> ## ## > >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > >> ## Wiki: http://cgiapp.erlbaum.net/ ## > >> ## ## > >> ################################################################ > >> > >> > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
|
|
Re: Adding a div of fixed content to evey page. Possible?I see what your problem is now..
I have had to deal with this in the past the way I handled it was to split up my rm content, save one of them to a cgi::app parameter and then pull it back out in postrun runmode { #generate content1 $self->param('Content1',$Content1); #generate content 2 return $Content2; } postrun { my $Content1=$self->param('Content1'); my $Content2=$$output_ref; my $LoginForm=&Get_LoginForm_HTML; $template->param( CONTENT1 => $Content1, LOGINFORM =>$LoginForm, CONTENT2 => $Content2, ); } I then used a <TMPL_IF> statements to only show CONTENT1 if it's populated. It seemed a little hackish and messy to me at the time, but it was the best I could think of. There probably is a much better way. Let me know what method you end up going with. Gurunandan R. Bhat wrote: > <div>Banner</div> > <div>Left Column</div> > <div> > Some Business Content > <div>Login Box Here</div> > More Business Content > </div> > > > > > On Fri, 2009-10-30 at 16:04 -0400, Brad Van Sickle wrote: > >> I have a hard time imagining a scenario where you couldn't make it work >> with some clever templating, but you certainly know your requirements >> better than I do. Perhaps if you could provide me an example of HTML >> layout I might have a better idea about what you're talking about? >> >> Hopefully this is at least useful to you in a future project. >> >>> >>> Gurunandan R. Bhat wrote: >>> >>>> Now I get it! Thanks for staying with me. >>>> However my point is that I cannot do this: >>>> >>>> >>>> >>>>> # Fill in template parameters >>>>> $template->param( >>>>> WIDGET1 => $widget1, >>>>> WIDGET2 => $widget2, >>>>> RUNMODE_CONTENT => $$output_ref, >>>>> ); >>>>> >>>>> >>>> for any layout - specifically where the design (HTML) of the page is such that it does not allow cleanly separating the widgets from the surrounding content. >>>> Unfortunately I have a layout where the business output from the runmodes cannot be cleanly separated from the fixed content (in my case a login form). >>>> >>>> However in situations where such a separation in possible, yours is an excellent and preferred solution, So Thanks >>>> >>>> >>>> >>>> On Fri, 2009-10-30 at 15:25 -0400, Brad Van Sickle wrote: >>>> >>>> >>>>> My postrun sits in a superclass, so I have one "postrun" that serves the >>>>> entire application. >>>>> >>>>> From within that postrun I do something similar to the following: >>>>> >>>>> postrun >>>>> { >>>>> #load page framework template >>>>> my $template = $self->load_tmpl( >>>>> $TemplateFile, >>>>> cache => 1, >>>>> die_on_bad_params =>0, >>>>> ); >>>>> >>>>> #get "widget" content >>>>> my $widget1=&Get_Widget1; #return html to insert into widget1 >>>>> my $widget2=$Get_Widget2; #return html to insert into widget2 >>>>> >>>>> # Fill in template parameters >>>>> $template->param( >>>>> WIDGET1 => $widget1, >>>>> WIDGET2 => $widget2, >>>>> RUNMODE_CONTENT => $$output_ref, >>>>> ); >>>>> >>>>> #overwrite the output with the output of the template >>>>> $$output_ref= $template->output; >>>>> } >>>>> >>>>> Then in my runmode: >>>>> >>>>> runmode >>>>> { >>>>> ################ >>>>> #get output >>>>> ################ >>>>> >>>>> #load rumode template that has only the html for this section, not >>>>> the full page >>>>> my $template = $self->load_tmpl( >>>>> $RMTemplateFile, >>>>> cache => 1, >>>>> die_on_bad_params =>0, >>>>> ); >>>>> >>>>> # Fill in template parameters >>>>> $template->param( >>>>> WHATEVER1 => $var1 >>>>> WHATEVER2 => $var2 >>>>> ); >>>>> >>>>> #return formatted runmode content content to postrun >>>>> return $template->output; >>>>> } >>>>> >>>>> This allows me to control the format of my runmode output, and then >>>>> stick that formatted content into an overall page template. Since I >>>>> have postrun in a superclass, and it services my entire application, I >>>>> only have one piece of code to track. >>>>> >>>>> I'm sure this isn't the only option, (in fact the other responses seem >>>>> like they would work as well) but for the projects I've used this method >>>>> on I've been really pleased with the combination of flexibility and >>>>> centralized code management it provides. >>>>> >>>>> >>>>> >>>>> Gurunandan R. Bhat wrote: >>>>> >>>>> >>>>>> First, Thanks for responding. >>>>>> >>>>>> Are you suggesting that I populate a template variable with another >>>>>> HTML::Template-tagged piece and then populate that piece in postrun? If >>>>>> yes, wouldn't I have to do that in every runmode - something that I >>>>>> wanted to avoid? >>>>>> >>>>>> Would it not be better if I called $app->param(LOGINFORM => 'Content of >>>>>> Form') (as opposed to $tpl->param()) in prerun and have it set for every >>>>>> runmode without doing so explicitly in each runmode? >>>>>> >>>>>> I am not getting it. My bad, obviously >>>>>> >>>>>> >>>>>> On Fri, 2009-10-30 at 14:55 -0400, Brad Van Sickle wrote: >>>>>> >>>>>> >>>>>> >>>>>>> You can initialize and populate your template in postrun as well. >>>>>>> >>>>>>> The way I do it is I typically load the framework of the page using >>>>>>> HTML::Template in postrun, and then insert the output of my runmode into >>>>>>> the template where required. >>>>>>> >>>>>>> If your runmode output is complex enough to require being templated >>>>>>> itself, there isn't anything stopping you from using HTML::Template >>>>>>> within the runmode to format the output and then inserting the output of >>>>>>> that template into the overall template in postrun. >>>>>>> >>>>>>> You can even move postrun up into a superclass to centralize all of this >>>>>>> content and keep a coherent look on your site. >>>>>>> >>>>>>> At least that's the easiest and most flexible solution I found when I >>>>>>> was faced with a similar problem... >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> Gurunandan R. Bhat wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Yes thats what I want to do. To be specific, I want to insert a login >>>>>>>>> form on every page or a logged-in status depending on whether >>>>>>>>> $app->authen->username is defined or not (I am using >>>>>>>>> CAP-Authentication). >>>>>>>>> >>>>>>>>> But when I am in post-run, HTML::Template has done its job and no >>>>>>>>> template variables are available any more - unless I use another >>>>>>>>> templating system that will process the plain text available in postrun. >>>>>>>>> In the light of this I am not sure how your suggestion will work. >>>>>>>>> >>>>>>>>> Unless I haven't really understood what is available to postrun. >>>>>>>>> >>>>>>>>> REgards >>>>>>>>> Gurunandan >>>>>>>>> >>>>>>>>> >>>>>>>>> On Fri, 2009-10-30 at 14:40 -0400, Brad Van Sickle wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> In postrun you can populate a variable with a subroutine call and then >>>>>>>>>> substitute that variable anywhere in your template, or even insert it >>>>>>>>>> into your runmode output if desired. >>>>>>>>>> >>>>>>>>>> Is that what you are looking for, or am I way off base? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Gurunandan R. Bhat wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> Is it possible to add the output of a template to every page/run-mode >>>>>>>>>>> without going through assigning it to a template->param in each >>>>>>>>>>> run-mode? >>>>>>>>>>> >>>>>>>>>>> I am aware of using cgi-postrun to wrap the output of a run-mode, but it >>>>>>>>>>> seems not possible to *insert* a div of content in an arbitraty (but >>>>>>>>>>> fixed position) using this trick. Or is it? >>>>>>>>>>> >>>>>>>>>>> I would also like to avoid another template processor (like HTML::Mason >>>>>>>>>>> or Text::Template) to do this if there is an easier way. >>>>>>>>>>> >>>>>>>>>>> Thanks for your attention >>>>>>>>>>> Gurunandan >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> ##### CGI::Application community mailing list ################ >>>>>>>>>>> ## ## >>>>>>>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>>>>>>> ## ## >>>>>>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>>>>>>> ## ## >>>>>>>>>>> ################################################################ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> ##### CGI::Application community mailing list ################ >>>>>>>>>> ## ## >>>>>>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>>>>>> ## ## >>>>>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>>>>>> ## ## >>>>>>>>>> ################################################################ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> ##### CGI::Application community mailing list ################ >>>>>>>>> ## ## >>>>>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>>>>> ## ## >>>>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>>>>> ## ## >>>>>>>>> ################################################################ >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>> ##### CGI::Application community mailing list ################ >>>>>>> ## ## >>>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>>> ## ## >>>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>>> ## ## >>>>>>> ################################################################ >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> ##### CGI::Application community mailing list ################ >>>>>> ## ## >>>>>> ## To unsubscribe, or change your message delivery options, ## >>>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>>> ## ## >>>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>>> ## ## >>>>>> ################################################################ >>>>>> >>>>>> >>>>>> >>>>>> >>>>> ##### CGI::Application community mailing list ################ >>>>> ## ## >>>>> ## To unsubscribe, or change your message delivery options, ## >>>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>>> ## ## >>>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>>> ## ## >>>>> ################################################################ >>>>> >>>>> >>>>> >>>> >>>> ##### CGI::Application community mailing list ################ >>>> ## ## >>>> ## To unsubscribe, or change your message delivery options, ## >>>> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >>>> ## ## >>>> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >>>> ## Wiki: http://cgiapp.erlbaum.net/ ## >>>> ## ## >>>> ################################################################ >>>> >>>> >>>> >> ##### CGI::Application community mailing list ################ >> ## ## >> ## To unsubscribe, or change your message delivery options, ## >> ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >> ## ## >> ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >> ## Wiki: http://cgiapp.erlbaum.net/ ## >> ## ## >> ################################################################ >> >> > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |