I would like to use the same header file in both GCommunity and GLinks, preferable include_header and include_footer which I am using in GLinks. Is there a way to include these files instead of having to make a duplicate copy for both? I'm not sure SSI would work.
Aug 17, 2006, 10:52 PM
Enthusiast (854 posts)
Aug 17, 2006, 10:52 PM
Post #2 of 7
Views: 2486
You could use a template global to handle that...
my $template = shift;
my $path = '/path/to/other/templates';
my $tpl;
open (TPL, $path . "/" . $template) or return "Cannot load file $path\/$template. $!";
while (<TPL>) { $tpl .= $_; }
close (TPL);
return $tpl;
}
It would be nice if <%include%>'s supported this by default.
Philip
------------------
Limecat is not pleased.
Code:
sub { my $template = shift;
my $path = '/path/to/other/templates';
my $tpl;
open (TPL, $path . "/" . $template) or return "Cannot load file $path\/$template. $!";
while (<TPL>) { $tpl .= $_; }
close (TPL);
return $tpl;
}
It would be nice if <%include%>'s supported this by default.
Philip
------------------
Limecat is not pleased.
Aug 17, 2006, 11:04 PM
Staff (4101 posts)
Aug 17, 2006, 11:04 PM
Post #3 of 7
Views: 2480
You can include from absolute/relative paths as long as it's not done via a variable. eg. you can do <%include /path/to/other/templates/foo.html%>, but you can't do <%set tpl = "/path/to/other/templates/foo.html"%><%include $foo%> due to security restrictions.
Adrian
Adrian
Aug 18, 2006, 12:04 AM
Enthusiast (854 posts)
Aug 18, 2006, 12:04 AM
Post #4 of 7
Views: 2485
hm... okay, the template tuturial is incorrect then:
Philip
------------------
Limecat is not pleased.
Quote:
...will include either the file info.txt (if info is true) or noinfo.txt (if info is false or not set). It must be in the template's root directory which is defined using $obj->root, or '.' by default.Philip
------------------
Limecat is not pleased.
I tried to include:
/var/home/user/wiredbiz.com/cgi-bin/links/admin/templates/luna/include_header.html
And got a "no such file" or directory error. Where do I need to start the path from?
I also put a header file in my www directory, and tried:
/var/home/user/wiredbiz.com/www/include_header.html
and
/include_header.html
And no luck.
Thanks!
Aug 18, 2006, 8:01 AM
Enthusiast (559 posts)
Aug 18, 2006, 8:01 AM
Post #6 of 7
Views: 2474
I think you need to add local:
<%include /var/home/user/wiredbiz.com/cgi-bin/links/admin/templates/luna/local/include_header.html%>
I've tried it and it works ok.
Code:
<%include /var/home/user/wiredbiz.com/cgi-bin/links/admin/templates/luna/include_header.html%> <%include /var/home/user/wiredbiz.com/cgi-bin/links/admin/templates/luna/local/include_header.html%>
I've tried it and it works ok.