Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How Do I Add The Same Header To Every Page?

Quote Reply
How Do I Add The Same Header To Every Page?
I was wondering if anyone knew how to add the same header to every page links builds.

thanx
Quote Reply
Re: How Do I Add The Same Header To Every Page? In reply to
If you are not using templates, go into site_html.pl and add something like this at the top of the script in the Global section:

Quote:
$site_header = qq|your header html code here|;

That variable is then available for use in any of the site_html.pl subroutines.

If you are using templates, do the same thing in site_html_templates.pl but be sure it is put above the %globals array. Then, in the %globals array, add the following at the top of the list:

Quote:
site_header => $site_header,

You can now use $site_header in any of the site_html_templates.pl subroutines and <%site_header%> in any of the template files.

I hope this helps.
Quote Reply
Re: How Do I Add The Same Header To Every Page? In reply to
Ok ... heres the subroutine
Code:
sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.

return &load_template ('home.html', {
category => $category,
grand_total => $grand_total,
%globals
});
}

Can you show me exactly what to add to this to make the header appear automatically without haveing to edit the template?

thanks
Quote Reply
Re: How Do I Add The Same Header To Every Page? In reply to
You wouldn't need to add anything to that subroutine. You need to scroll back up to the top of the site_html_templates.pl document, and looks for the section like this:
Code:
# You can put variables here that you would like to use in any
# of your templates.

%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
banner => ''
);

Right before that section, you want to add
Quote:
$site_header = qq|your header html code here|;
and then in the section I posted above, right below the css=> line, add
Quote:
site_header => $site_header,

You don't have to change anything else in this file. However you do have to go into each template where you want the header to show up and add <%site_header%> where you want the header text to be.

Can't do it without editing each template at least that much.

Phoenix
Quote Reply
Re: How Do I Add The Same Header To Every Page? In reply to
You know, I tried this for a site wide footer; it worked, but I noticed a significant slow down during page build. I kept it in place for several builds to account for server load fluctuations. Eventually, I reverted to just having it in the templates and building picked right back up. Is this normal? I did have quite a bit of code in there, but I didn't think parsing it from the pl file would make that much difference.

I guess it doesn't matter all that much in the long...I have a good search and replace program that makes mass changes to things like standard footers pretty simple. My footers don't change very often anyway, so its not that big of a deal. I am curious if this behavior is normal though.
Quote Reply
Re: How Do I Add The Same Header To Every Page? In reply to
Brad,
I haven't used this same method, but I've used the include syntax from the Nested Ifs mod to include a site-wide header and footer in my pages. I haven't noticed a decrease in speed, but I couldn't guess if it were due to using a different method, or just different server configs.

Phoenix