Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Different Headers for Different Pages?


Guest

Recommended Posts

Forgive me if this has been asked; did a search and didn't find what I was looking for.

 

What I'd like to do is have different headers for different pages.

 

For example, if a person is on index.php or product_info.php, header1 is shown.

 

If a person is on contact_us.php or information.php, header2 is shown.

 

And so on..

 

What would be the best way to accomplish this?

Link to comment
Share on other sites

I use a different header for my homepage, to the header I use for all others. I use some 'slogan' text on the homepage in place of the breadcrumb trail - no point in having a breadcrumb trail on the homepage!

 

Just open includes/header.php and select 'Save As' and name it to something else e.g. header2.php - and then amend it as you want. On the page you want that header to appear on, where the header is 'included', just 'include' header2.php and not header.php.

 

Vger

Link to comment
Share on other sites

Well, I'm using BTS, and the only place I see that includes the header is in the main_page.tpl.php. All the other files in the catalog directory, make reference to using the .tpl.php files...

 

Seems like it would be a simple matter of saying

if something = index.php {
include header1.php

and so on. My confusion is coming in at defining how to say (for example) if something doesn't equal index.php but equals contact_us.php then it should include header2. If it doesn't equal index or contact_us but equals product_info.php it should include header3. If it doesn't equal any of those it should use header4.

 

Hope this makes sense.

Link to comment
Share on other sites

and so on. My confusion is coming in at defining how to say (for example) if something doesn't equal index.php but equals contact_us.php then it should include header2. If it doesn't equal index or contact_us but equals product_info.php it should include header3. If it doesn't equal any of those it should use header4.

Use something like this:
if (basename($PHP_SELF) == FILENAME_DEFAULT) {
//code for index page goes here
else
//other pages go here
}

If you are going to check for a number of pages, then a switch statement might be better.

 

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

check www.beachbums.com

 

it uses different headers and left columns per category selected.

 

just have different header files and put them in a if clause to include it after reading the category the user has selected.

 

thanks

Link to comment
Share on other sites

Thanks for your help, everyone :).

 

Got it to work by doing the following:

$myurl = (basename($PHP_SELF));
switch ($myurl) {
case 'index.php':
require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/header1.php');
break;
case 'information.php':
require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/header2.php');
break;
case 'contact_us.php':
require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/header3.php');
break;
default: 
require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/header4.php');
}

Works like a charm now! :D

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...