Gossamer Forum
Home : Products : Links 2.0 : Customization :

Including Files with Enchanced Templates

Quote Reply
Including Files with Enchanced Templates
G'day I have installed the enchanced template mod and it works well except the tag

<%include <%header%>%>

doesn't work. I get the message
"Can't find file: /data1/hypermart.net/internet-bucks/advertisingh.html" when that file does exist and the path is correct

The command <%include something.html%> works.

I would greatly appreciate it if someone could help me!

Thanks in Advance
Quote Reply
Re: Including Files with Enchanced Templates In reply to
 
Quote:
The command <%include something.html%> works.

I think you have it right there and you say that works. So, I am not sure what you are asking for.
Quote Reply
Re: Including Files with Enchanced Templates In reply to
I don't know if you notice, but you have them both differently, so if one works for one, why not ry it for the other.
<%include <%header%>%>
to
<%include header%>
Quote Reply
Re: Including Files with Enchanced Templates In reply to
I'm sorry my message must not have been very clear.

I want to include a different header file for each category page, and this filename is stored in the header field of the database.

So i tried the command <%include <%header%>%> and this doesn't work.

Thanks
Quote Reply
Re: Including Files with Enchanced Templates In reply to
The way I have Links setup is that I need to insert a text file as a header. I have used the <%header%> field to store the name of the text file.

I did use the SSI tag <!--#include virtual="/<%header%>"--> and it worked fine except it was pretty heavy on the server, so that is why I want to use a different method.

In theory the tag below should do the exact same thing
<%include <%header%>%> but I get an error message
Quote Reply
Re: Including Files with Enchanced Templates In reply to
Erm, perhaps i'm missing something, but isn't <%header%> all you need to enter if your using the header field ?

------------------
Craig Antill
10 Tenths Motorsport - www.Ten-Tenths.com/links/
Parc Ferme Magazine - www.Ten-Tenths.com/Parc_Ferme/
THE Directory - www.gardenbuildings.com/

Quote Reply
Re: Including Files with Enchanced Templates In reply to
You should save that file as header.txt in your templates directory and then just include, <%include header.txt%> on your pages.

Is that what you want?
Quote Reply
Re: Including Files with Enchanced Templates In reply to
That isn't really what I want. I want to include a different header file for each page. That is why I have stored the header filename in the variable <%header%>.

Thanks
Quote Reply
Re: Including Files with Enchanced Templates In reply to
OK, then try this:

Save your different header files with different names in your templates directory (not sure if it will work in any directory) and then, in your category header input, the place where you create categories, just insert the complete locations (try both url and path) to that file. That should pull in the header either as a text file or as a html file.
Quote Reply
Re: Including Files with Enchanced Templates In reply to
Hello, Daniel,
I want to do the same thing as you.
(<%include <%header.txt%>%> )
Do you get the answer?
Quote Reply
Re: Including Files with Enchanced Templates In reply to
I did it.
In sub parse, I added the following code right before:
# Parse includes, do this first so that the includes can include..

Code:
my $begin2 = $self->{'begin2'} &#0124; &#0124; quotemeta('<<');
my $end2 = $self->{'end2'} &#0124; &#0124; quotemeta('>>');
$temp =~ s/$begin2\s*(.+?)\s*$end2/
if (exists $self->{'vars'}{$1}) {
ref ($self->{'vars'}{$1}) eq 'CODE' ?
&{$self->{'vars'}{$1}}($self->{'vars'}) : $self->{'vars'}{$1};
}
else { "Unkown Tag: $1"; }
/goe;
Quote Reply
Re: Including Files with Enchanced Templates In reply to
Fortune,

I tried your mod, but I still get the same error message.

Does it work for you? If so can you show me your whole sub parse.

Thanks
Quote Reply
Re: Including Files with Enchanced Templates In reply to
You have to use <%include <<header>>%> instead of <%include <%header%>%> in your template.
It will parse <<header>> first, then <%include%> and <%other%> at last.
Quote Reply
Re: Including Files with Enchanced Templates In reply to
Thanks.

It works like a treat!
Quote Reply
Re: Including Files with Enchanced Templates In reply to
As a follow up to this thread ...

The include function appears to look in the /templates directory by default. I'd like to point to files outside of this directory. I've tried relative paths etc. but to no avail (the path to the templates directory is always included).

Any suggestions?

Thanks -
Quote Reply
Re: Including Files with Enchanced Templates In reply to
I too am making a mod that would need to pull text files from elsewhere than the templates directory. Anyone figured out how to do this? I keep getting
"Can't find file: /home/path/to/templates/http://dbink.hostingcheck.com/library/files/rpg/add/articletrain1.txt", I just want to reference the URL. does it have to be the absolute path to the file? if so, how can I take the contents of a field and parse off part of it so I can create an absolute path?


------------------
Marie Altobelli
Dragonsblood Ink. Librarian
http://dbink.hostingcheck.com
Quote Reply
Re: Including Files with Enchanced Templates In reply to
Very easy (not so easy in Links SQL Frown ):

In site_html_templates.pl, above %globals, add:

$site_footer = qq~</TD></TR></TABLE>~;
$file = "/path/to/filename.txt";
open (FILE, $file2) or die "Can't open $file ($!)";
@lines = <FILE>;
close FILE;
foreach $line (@lines) {
$site_footer .= $line;
}

Then add:

site_footer => $site_footer,

to the %globals, and finally, add <%site_footer%> anywhere you want in your templates. Of course, you can name it anything you want; doesn't have to be site_footer.

Dan
Quote Reply
Re: Including Files with Enchanced Templates In reply to
whoops, I guess I wasn't clear Dan, sorry about that. I'm referencing a different file for each record. I need to take what's in the URL field (for example
'http://dbink.hostingcheck.com/library/files/rpg/add/articletrain1.txt'), and turn it into
'/home/dbink/dbink-www/library/files/rpg/add/articletrain1.txt'.
all the URLs reference files on my site, so even if I could take the first 29 characters off of what's in the URL field, then paste whats left behind the absolute path to the primary directory, that should work. or maybe there's an easier way?


------------------
Marie Altobelli
Dragonsblood Ink. Librarian
http://dbink.hostingcheck.com
Quote Reply
Re: [Fortune] Including Files with Enchanced Templates In reply to
Do you have an idea haw to include file from parameter?

script.cgi?user=test

and then to includu file test.txt

<%include <%user%>.txt%>

Thanks for you help!