Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Using "header" to include files

Quote Reply
Using "header" to include files
Hi!
In Links 2.0 i used the tag <%include <<header>>%> in the category-templates, so that I could include a different file in each category. There is a thread in the Links 2.0 modification forum about this.
(Started by Daniell Linsell nov -99)

You had to add this code in sub parse right before:

# Parse includes, do this first so that the includes can include..

code:


my $begin2 = $self->{'begin2'} | | quotemeta('<<');
my $end2 = $self->{'end2'} | | 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;

This is working great in Links 2.0. Can I do a similar thing in Links Sql?

Kjetil

Quote Reply
Re: Using "header" to include files In reply to
You can do something similar by changing the header/footer file in each of the category descriptions.

There are several threads on this in the past few months.

Quote Reply
Re: Using "header" to include files In reply to
Its working! I did the exact same thing as in Links 2.0.

I edited Template.pm, and added this code in sub parse right before:

# Parse includes, do this first so that the includes can include..

code:


my $begin2 = $self->{'begin2'} | | quotemeta('<<');
my $end2 = $self->{'end2'} | | 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;


Then you can use this tag in the "category.html" template: <%include <<header>>%>

In the Header field of the category descriptions, you can then specify a different file for each category if you want.
ex file1.txt or file2.txt.
Different files are included with diferent categories.

This is a very powerful mod. Maybe something for the faq?

Kjetil