Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Different Header for contact page?

Different Header for contact page?

Views: 6,583

Results 1 to 20 of 30
6 Apr 2007, 4:15 PM
#1
rpbenton avatar

rpbenton

New Zenner

Join Date:
Apr 2007
Posts:
6
Plugin Contributions:
0

Different Header for contact page?

Is it possible to change have a different header on a certain page? I want to have the contact page of my site refer to a different image map, either in a seperate tpl_header.php file, or from a code contained in the tpl_main_page.php. I figured out how to disable the header for the page, but can't figure out how to add a different one. Thanks!

6 Apr 2007, 8:33 PM
#2
rpbenton avatar

rpbenton

New Zenner

Join Date:
Apr 2007
Posts:
6
Plugin Contributions:
0

Re: Different Header for contact page?

I figured it out. If anyone else was wondering, open your tpl_main_page file and find the mainWrapper div. Add an if/else statement pointing to another header page. The first section is the page you want to be different.

<div id="mainWrapper"> <?php /** * prepares and displays header output * */ if (in_array($current_page_base,explode(",",'contact_us,conditions')) ) { require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');} else require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>
23 May 2007, 3:49 AM
#3
keenskin avatar

keenskin

New Zenner

Join Date:
Nov 2005
Posts:
49
Plugin Contributions:
0

Re: Different Header for contact page?

thank for your solution, it worked for me, too!! except "TEMPLAT E" should be "TEMPLATE"

two questions,
if i want to have more than two tpl_header.php, for example, tpl_header2.php, tpl_header3.php, tpl_header4.php, etc.
how could i make it possible

and how can i use one of ezpage to have one of tpl_header.php
"contact_us,conditions" are no problem, but for ezpage, it just look like this
mydomain.com/index.php?main_page=page&id=1&chapter=0

many thanks

23 May 2007, 4:05 AM
#4
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Different Header for contact page?

keenskin:

thank for your solution, it worked for me, too!! except "TEMPLAT E" should be "TEMPLATE"

two questions,
if i want to have more than two tpl_header.php, for example, tpl_header2.php, tpl_header3.php, tpl_header4.php, etc.
how could i make it possible

and how can i use one of ezpage to have one of tpl_header.php
"contact_us,conditions" are no problem, but for ezpage, it just look like this
mydomain.com/index.php?main_page=page&id=1&chapter=0

many thanks

Use the following: the highlighted portion would be the id for your ezPage
if (in_array($ezpage_id,explode(",",'7'))) {

}

25 Jul 2009, 9:53 PM
#5
loosefast avatar

loosefast

Zen Follower

Join Date:
Jun 2005
Posts:
199
Plugin Contributions:
0

Re: Different Header for contact page?

Thanks for this function!

What would be the IF statement to use for Category pages? Also, categories with sub-categories.

I tried this:

if (in_array($current_page_base,explode(",",'index&cPath=2_6,contact_us,conditions')) ) {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');}

And it does not work.

Thanks

25 Jul 2009, 10:40 PM
#6
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Different Header for contact page?

loosefast:

Thanks for this function!

What would be the IF statement to use for Category pages? Also, categories with sub-categories.

I tried this:

if (in_array($current_page_base,explode(",",'index&cPath=2_6,contact_us,conditions')) ) {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');}

And it does not work.

Thanks

You'll need to use this

if ($current_page_base == 'index' and $cPath=='2_6' or $current_page_base == 'contact_us' or $current_page_base == 'conditions') {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}

25 Jul 2009, 11:09 PM
#7
helensama avatar

helensama

New Zenner

Join Date:
Dec 2006
Location:
Northwest Connecticut
Posts:
87
Plugin Contributions:
0

Re: Different Header for contact page?

Thanks for supplying this code. I am working on the same site as Loosefast and the Home page uses one header, all other pages use the other header i.e. header2.php. How would we specify the Home page? In other words the if statements would read:

If Home page

require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');

Else

require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');}

That way we don't have to specify the specific category, ez pages, contact page etc.

26 Jul 2009, 12:46 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Different Header for contact page?

if ($this_is_home_page) {
  require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');
}else{
  require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}

...well that was pretty close to simultaneous :)

26 Jul 2009, 12:46 AM
#9
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Different Header for contact page?

HelenSama:

Thanks for supplying this code. I am working on the same site as Loosefast and the Home page uses one header, all other pages use the other header i.e. header2.php. How would we specify the Home page? In other words the if statements would read:

If Home page

require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');

Else

require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');}

That way we don't have to specify the specific category, ez pages, contact page etc.

If ($this_is_home_page) {

require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');

} Else {

require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}

26 Jul 2009, 12:56 AM
#10
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Different Header for contact page?

To paraphrase an old doublemint commercial -

double the content, double the knowledge

26 Jul 2009, 1:23 AM
#11
loosefast avatar

loosefast

Zen Follower

Join Date:
Jun 2005
Posts:
199
Plugin Contributions:
0

Re: Different Header for contact page?

Clyde & Glenn,

Thanks very much!

tom

16 Jun 2011, 1:04 AM
#12
bachus avatar

bachus

New Zenner

Join Date:
Jun 2011
Posts:
6
Plugin Contributions:
0

Re: Different Header for contact page?

Hi, I am customizing 1.3.9h - not a programmer.

The solution you offered here seems to be conflicting with the code that follows. The result is two instances of tpl_header.php loading into the header space. How do I go around this problem?

Basically, what I am trying to archive is to have one fat header loaded with multimedia on the home page and regular slim ones (as predefined in the default zen template) on all other pages.

Thank you.

####################____

<?php
 /**
  * prepares and displays header output
  *
  */

If ($this_is_home_page) {
  require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');
  } Else {
  require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
  } 


  if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == '')) {
    $flag_disable_header = true;
  }
  require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>
16 Jun 2011, 1:04 AM
#13
bachus avatar

bachus

New Zenner

Join Date:
Jun 2011
Posts:
6
Plugin Contributions:
0

Re: Different Header for contact page?

<?php /** * prepares and displays header output * */ If ($this_is_home_page) { require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php'); } Else { require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php'); } if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == '')) { $flag_disable_header = true; } require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>
16 Jun 2011, 1:44 AM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Different Header for contact page?

The entire if ($this_is_home_page) { ... } code should replace the last require( .. ) statement. The require code should not be executed until the flag setting is determined. (Then if the disable is true, the header will not be output after any top-of-page alerts are output.)

16 Jun 2011, 2:05 AM
#15
bachus avatar

bachus

New Zenner

Join Date:
Jun 2011
Posts:
6
Plugin Contributions:
0

Re: Different Header for contact page?

gjh42:

The entire if ($this_is_home_page) { ... } code should replace the last require( .. ) statement.

Awesome. It worked. Thank you
Here is the magic tpl_main_page.php code for the non-technical posterity:

<?php /** * prepares and displays header output * */ if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 && CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true' and ($_SESSION['customers_authorization'] != 0 or $_SESSION['customer_id'] == '')) { $flag_disable_header = true; } If ($this_is_home_page) { require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php'); } Else { require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php'); } ?>

where tpl_header2.php contains a div with space for multimedia to go to the main page and tpl_header.php is a regular header for the rest of pages.

18 Oct 2011, 3:40 PM
#16
moesoap avatar

moesoap

Zen Follower

Join Date:
Mar 2010
Posts:
258
Plugin Contributions:
0

Re: Different Header for contact page?

clydejones:

You'll need to use this

if ($current_page_base == 'index' and $cPath=='2_6' or $current_page_base == 'contact_us' or $current_page_base == 'conditions') {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}

Can anyone suggest what code is required for the following link to change the header and footer?

http://www.example.com/index.php?main_page=document_product_info&cPath=123&products_id=229

18 Oct 2011, 4:20 PM
#17
moesoap avatar

moesoap

Zen Follower

Join Date:
Mar 2010
Posts:
258
Plugin Contributions:
0

Re: Different Header for contact page?

I have tried this but cannot get it to work

if ($current_page_base == 'main_page=document_product_info' and $cPath=='123' and $products_id=='229') {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}
else
require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>

:unsure:

18 Oct 2011, 5:18 PM
#18
isotonic1 avatar

isotonic1

New Zenner

Join Date:
Oct 2011
Posts:
3
Plugin Contributions:
0

Re: Different Header for contact page?

moesoap:

I have tried this but cannot get it to work

if ($current_page_base == 'main_page=document_product_info' and $cPath=='123' and $products_id=='229') {
require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');
}
else
require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>

> 
> :unsure:

have you fixed this as me to having same worry, header needed for certain product_info page only and footer
18 Oct 2011, 5:23 PM
#19
moesoap avatar

moesoap

Zen Follower

Join Date:
Mar 2010
Posts:
258
Plugin Contributions:
0

Re: Different Header for contact page?

No I haven't fixed this yet. The footer would be the easy part as it is the same code as header except of course it would state tpl_footer2.php rather than tpl_header2.php.

I'll post the solution here if I ever figure it out.

18 Oct 2011, 5:31 PM
#20
isotonic1 avatar

isotonic1

New Zenner

Join Date:
Oct 2011
Posts:
3
Plugin Contributions:
0

Re: Different Header for contact page?

i make mistake my worry is not this