Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Why isn't the Header tag in the header?


wizardsandwars

Recommended Posts

OK, I've done alot of customizations, and template integrations, going back to v2.1. But lately, one of the things that bothers me is the header tag. I often need to insert javascript definition, or rollovers, or whatever, before the closing header tag, and I was just wondering why isn't the entire header tag in the header.php, instead of having it on each page.

 

For kicks, in the last cart I put together for someone, www.cellbusters.com, I did just that. It's seems to work pretty well. And it's so obvious, that I have to wonder what I might have overlooked?

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

I'm confused by what you mean by "header tag." That is the name for the h1 through h6 tags. Do you mean the head section perhaps? Or maybe the title and meta tags (from Header Tags)?

 

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Yeah, sorry, keep in mind I'm an SQL, and procedural logic guy. HTML isn't my native language, lol.

 

I meant the <head> </head> section. I often find myself needing to add code before the </head> tag, and it seems like a bit of a pain to have to add it for each individual page. If you put the <head> </head> section in the header, then you only have to add those things to one place.

 

I suppose the argument is that each page may have a different set of javascript, or whatever, that it will need, and that putting it all in one file, to be read each time the page is called whether it needs it or not is inefficient. I guess I am questioning how inefficient that would be? On larger sites would it *really* slow things down?

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

So it sounds like what you are asking, at least in part, is if you can move tags meant for the head section to the body section? The HTML standard says certain tags should be in the head section. If the meta tags, for example, were moved to the body section, I suspect the site would still load. But it would probably cause quite a few validation errors to popup. It might even break some browsers. As for javascript though, I usually place mine in the header.php file as you mention (via an external file). I've seen mention that any function calls that javascript uses should go in the head section but I think that is a guideline more than a rule. Perhaps any javascript experts reading this can clarify. In any event, I've not seen any ill-effects come about by doing so.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

OK, I've done alot of customizations, and template integrations, going back to v2.1. But lately, one of the things that bothers me is the header tag. I often need to insert javascript definition, or rollovers, or whatever, before the closing header tag, and I was just wondering why isn't the entire header tag in the header.php, instead of having it on each page.

 

For kicks, in the last cart I put together for someone, www.cellbusters.com, I did just that. It's seems to work pretty well. And it's so obvious, that I have to wonder what I might have overlooked?

 

I've found exactly the same thing. I've got some javascript I want to include and it looks like it going in each file :'(

Link to comment
Share on other sites

So it sounds like what you are asking, at least in part, is if you can move tags meant for the head section to the body section? The HTML standard says certain tags should be in the head section. If the meta tags, for example, were moved to the body section, I suspect the site would still load. But it would probably cause quite a few validation errors to popup. It might even break some browsers.  As for javascript though, I usually place mine in the header.php file as you mention (via an external file). I've seen mention that any function calls that javascript uses should go in the head section but I think that is a guideline more than a rule. Perhaps any javascript experts reading this can clarify. In any event, I've not seen any ill-effects come about by doing so.

 

Jack

 

There's nothing wrong with putting it within the <body></body> tags, I just liked to put it between the <head></head> tags.

Link to comment
Share on other sites

So it sounds like what you are asking, at least in part, is if you can move tags meant for the head section to the body section? ...

 

Jack

 

 

Well, almost. I was thinking more of putting the bady tag into the header as well, so the head tags still come first, the body tag next, all in the header. Then the index.php would start with the first table tag.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

The only exception to all the other pages, thinking quickly that is!, is the checkout payment page.

<?php echo $payment_modules->javascript_validation(); ?>

For most / some things putting javascript in the body is ok, but there are instances where the script must be available prior to loading the actual document body.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...