[REPOST - Original attachment stripped by filter.]
William,
Thank you for your efforts and sorry for your trouble. I hope the below explanation shows you what's going on and allows you to fix your installation. See attached file for three versions of C::A::load_tmpl() referred to below. Please let me know either way!
Everything looks correct. I did a bit more digging and dumped the value of tmpl_path which looks like this:
$VAR1 = '/home/flexmart/local/flexmart/fmdemo/tmpl:/home/flexmart/local/flexmart/flexmart/pgman/tmpl';
I assume that contains a correct path...
My reading of the docs[1] indicates that this is not standard usage to concatenate pathnames by colons; multiple paths should be given in an array ref. I tried changing the return value to an array ref using the following code in line 213 of HTMLTemplate.pm:
return [split(/:/,$tmpl_path)];
Unfortunately, this still is not working which makes me think there is a problem with how the templates are being told to be found. I don't use HTML::Template so may be completely off-base. You don't perhaps have HTML_TEMPLATE_ROOT set in your environment do you? Any further ideas? BTW, I'm running this code on Debian Linux. What OS are you using?
What version of CGI::Application are you using? Version 3.22 C::A contains a bug in handling the array ref with multiple paths, so your fix won't work even though the docs say it should. This is the second and final place I broke encapsulation to get my framework working because I figured this was a bug that would be quickly fixed and I wanted to support multiple paths for templates (one fo system templates and one for site-specific templates). I think your fix should work with version 3.31 of C::A, however. Upon my own testing and confirmation, that will be the solution going forward as well, as it complies with C::A docs.
Or, if need be, you can override C::A::load_tmpl() in FlexMart::AppBase with load_tmpl() as given by the code snippet following "3.22 modified" in the attached file. Notice the change / addition in the last two lines of the if clause. This is a hack which may break other functionality of C::A. I think 3.31 fixes the problem of sending an array ref for multiple paths, as documented.
Ah, I think I've found it. You don't use tmpl_load from C::A so tmpl_path is superfluous.
This is not correct; please see line 74 of FlexMart::PageManager::HTMLTemplate.
Bill
--------------------------------------------------------------------------------
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
### 3.22 orig
sub load_tmpl {
my $self = shift;
my ($tmpl_file, @extra_params) = @_;# add tmpl_path to path array of one is set, otherwise add a path arg
if (my $tmpl_path = $self->tmpl_path) {
my $found = 0;
for( my $x = 0; $x < @extra_params; $x += 2 ) {
if ($extra_params[$x] eq 'path' and ref $extra_params[$x+1] and
ref $extra_params[$x+1] eq 'ARRAY') {
unshift @{$extra_params[$x+1]}, $tmpl_path;
$found = 1;
last;
}
}
push(@extra_params, path => [ $tmpl_path ]) unless $found;
}
require HTML::Template;
my $t = HTML::Template->new_file($tmpl_file, @extra_params);return $t; }
### 3.22 modified
sub load_tmpl {
my $self = shift;
my ($tmpl_file, @extra_params) = @_;# add tmpl_path to path array of one is set, otherwise add a path arg
if (my $tmpl_path = $self->tmpl_path) {
my $found = 0;
for( my $x = 0; $x < @extra_params; $x += 2 ) {
if ($extra_params[$x] eq 'path' and ref $extra_params[$x+1] and
ref $extra_params[$x+1] eq 'ARRAY') {
unshift @{$extra_params[$x+1]}, $tmpl_path;
$found = 1;
last;
}
}
my @tmpl_paths = split( /:/, $tmpl_path );
push(@extra_params, path => [EMAIL PROTECTED] ) unless $found;
}
require HTML::Template;
my $t = HTML::Template->new_file($tmpl_file, @extra_params);return $t; }
### 3.31 orig
sub load_tmpl {
my $self = shift;
my ($tmpl_file, @extra_params) = @_;# add tmpl_path to path array if one is set, otherwise add a path arg
if (my $tmpl_path = $self->tmpl_path) {
my @tmpl_paths = (ref $tmpl_path eq 'ARRAY') ? @$tmpl_path : $tmpl_path;
my $found = 0;
for( my $x = 0; $x < @extra_params; $x += 2 ) {
if ($extra_params[$x] eq 'path' and ref $extra_params[$x+1] eq 'ARRAY') {
unshift @{$extra_params[$x+1]}, @tmpl_paths;
$found = 1;
last;
}
}
push(@extra_params, path => [ @tmpl_paths ]) unless $found;
}
require HTML::Template;
my $t = HTML::Template->new_file($tmpl_file, @extra_params);return $t; }
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
