Home : Products : Gossamer Links : Discussions :

Products: Gossamer Links: Discussions: Re: [pugdog] <%include %> insert not working: Edit Log

Here is the list of edits for this post
Re: [pugdog] <%include %> insert not working
I would like to be able to include a different banner HTML code in certain categories. For that I have created a new category column called "banner". I have then also created a directory "banners" in the admin directory and put a tiny HTML test file in it called test.html.

I then made the following (highlighted) additions to Build.pm

black text is what was there before, orange is what I added... :



# Get our output vars.
my %display;
$display{category_id} = $category->{'ID'};
$display{category_name} = $category->{'Full_Name'};
$display{header} = $category->{'Header'};
$display{footer} = $category->{'Footer'};
$display{banner} = $category->{'banner'};
$display{meta_name} = $category->{'Meta_Description'};
$display{meta_keywords} = $category->{'Meta_Keywords'};
$display{description} = $category->{'Description'};
$display{random} = int rand (10000);
$display{random1} = int rand (10000);
$display{random2} = int rand (10000);
$display{random3} = int rand (10000);


.... and then elsewhere :



# Get the header and footer from file if it exists, otherwise assume it is html.
if ($display{header} && (length($display{header}) < 20) && ($display{header} !~ /\s+/) && (-e "$CFG->{admin_root_path}/headers/$
display{header}")) {
open (HEAD, "<$CFG->{admin_root_path}/headers/$display{header}") or die "Unable to open header file: $CFG->{admin_root_path}
/headers/$display{header}. Reason: $!";
$display{header} = join "", <HEAD>;
close HEAD;
}

if ($display{footer} && (length($display{footer}) < 20) && ($display{footer} !~ /\s+/) && (-e "$CFG->{admin_root_path}/footers/$
display{footer}")) {
open (FOOT, "<$CFG->{admin_root_path}/footers/$display{footer}") or die "Unable to open footer file: $CFG->{admin_root_path}
/footers/$display{footer}. Reason: $!";
$display{footer} = join "", <FOOT>;
close FOOT;
}


# $display{banner} = $category->{'banner'}; ## this puts your new column in the output hash.

if ($display{banner}
&& (length($display{banner}) < 20)
&& ($display{banner} !~ /\s+/)
&& (-e "$CFG->{admin_root_path}/banners/$display{banner}"))
{
open (FOOT, "<$CFG->{admin_root_path}/banners/$display{banner}")
or die "Unable to open banner file: $CFG->{admin_root_path}/banners/$display{banner}. Reason: $!";


$display{banner} = join "", <FOOT>;

close FOOT;
}



While working on it, to test everything, I also created a directory "footers" in admin, same place I created "banners" directory.

I then also created a sample file for footers, basically doing the same thing that I did with the new "banner" and banners directory.

<%footer%> and <%banner%> were added in the template...

(footer is all lowercase here but it works even though it was defined as "Footer"...?)



Here is the weird thing, though the code seems identical (the original "footer" code and the new "banner" code), the footer does kick in and displays the contents of the test file, whereas the new banner displays the actual value of banner, which is the filename and not the HTML contents of the filename.

The code of the standard and original "footer" field and the new "banner" field seem identical, yet they behave differently. Is there some other area elsewhere that needs to be dealt with to make this work?

Also, I am not understanding what exactly the <FOOT> (in all caps) is and how come in the examples even though the "header" uses <HEAD> and "footer" uses <FOOT>, the new column (called "partner" in the example or "banner" in what I am doing) uses <FOOT> and not something else.

Do I have to compile Build.pm somehow or is the Build.pm executed 'live' ?





Here is the column definitions, just in case that has something to do with it?








PLEASE HELP Pirate

(THANKS)

Last edited by:

Peter544: May 16, 2003, 9:36 AM

Edit Log: