Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Different header/footer on home page only.

Different header/footer on home page only.

Views: 13,271

Results 1 to 20 of 32
10 Jan 2007, 6:48 PM
#1
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Different header/footer on home page only.

I understand how to override the header and footer for other pages, like the checkout or shopping cart, but I can't get it to work for the main page.

I tried putting a modified version of tpl_main_page.php into /templates/my_template/index, but it applies the changes to my product category pages, not only the home page.

Can anyone show me how to accomplish this using the $this_is_home_page variable?

I know the concept, but don't know how to implement the code.

Currently my header design is contained within a file called top.php which is called from whithin tpl_header.php.
I was thinking of creating a new file, top_main.php and calling it only when the current page is the home page.

Something like this:

if $this_is_home_page
{
include('top_main.php');
}
else
{
include('top.php');
}

I am completely lost when it comes to writing the actual code, and i'm not even sure this is the correct place to implement it.
My cart is version 1.3.6.

Any help would be appreciated.

10 Jan 2007, 7:25 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Different header/footer on home page only.

Well that's basically correct except that the if condition needs to go in brackets i.e. > if ($this_is_home_page)

4 Mar 2008, 4:48 AM
#3
chrispopovic avatar

chrispopovic

New Zenner

Join Date:
Sep 2007
Posts:
15
Plugin Contributions:
0

Re: Different header/footer on home page only.

I'm having a similar problem. It's cool to have a Flash header. But I only want it to run one time. I'd like to be able to control that in the flash movie. Right now, every time I go to a new page, the damn movie starts playing over again.

I'd like to get it to just stop one time. Or maybe it's easier to just change it out depending upon the category the user clicks on.

Boy I could really use some help here. Any advice is welcome.

Test site is at: http://208.106.156.104/ZenCart/:lamo:

4 Mar 2008, 5:17 AM
#4
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Different header/footer on home page only.

Admin > Tools > Pages Define Editor: define_main_page.php

Put your Flash code in there and it will only show on the Index page. If you want the Flash code on every page but not to run automatically, you would need to change your Flash code and make sure you have a Start / Stop button; similar to what you see at myspace.com.

4 Mar 2008, 5:21 AM
#5
chrispopovic avatar

chrispopovic

New Zenner

Join Date:
Sep 2007
Posts:
15
Plugin Contributions:
0

Re: Different header/footer on home page only.

I've got a stop in the actual flash file. I don't understand what you mean. Here's the entry I put into my tpl_header.php file.

<script type="text/javascript" src="includes/templates/red_passion/jscript/swfobject.js"></script> <div id="flashcontent"> This text is replaced by the Flash movie. </div> <script type="text/javascript"> var so = new SWFObject("includes/templates/red_passion/images/flash/hbtc_flash.swf", "HBTC", "840", "240", "0", "#ffffff"); so.write("flashcontent"); </script>

Can I put a simple "stop" in here some place?

4 Mar 2008, 5:32 AM
#6
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Different header/footer on home page only.

In order to have Start / Stop buttons you need to edit the (swf) file in whatever program you used to create the (swf) file.

4 Mar 2008, 6:11 AM
#7
chrispopovic avatar

chrispopovic

New Zenner

Join Date:
Sep 2007
Posts:
15
Plugin Contributions:
0

Re: Different header/footer on home page only.

I understand how to start/stop my flash file.

That's not the problem.

The problem is that every time I click on a link to navigate through my site, the flash file reloads and starts over again. It gets obnoxious to see that flash file reloading every time the user hits a link.

I've got to believe there's some option in javascript that will keep the file from reloading. Any jscript geniuses out th:blink:ere that can help?

4 Mar 2008, 6:57 AM
#8
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Different header/footer on home page only.

Quckest, easiest way is to create two header files,
one containing your flash code, which will show on
main index page, and 2nd header, for all other pages,
which contains static image of your fully loaded flash
file, for all other pages in zencart.
As per
http://www.zen-cart.com/forum/showpost.php?p=465944&postcount=4

5 Mar 2008, 1:43 AM
#9
chrispopovic avatar

chrispopovic

New Zenner

Join Date:
Sep 2007
Posts:
15
Plugin Contributions:
0

Re: Different header/footer on home page only.

Love that idea. However I have zero idea on how to execute something like that. Any chance you'd be interested in walking me through it?:blink:

31 Mar 2008, 9:26 AM
#10
digiteck avatar

digiteck

New Zenner

Join Date:
Mar 2008
Posts:
18
Plugin Contributions:
0

Re: Different header/footer on home page only.

I'm trying to place my flash header on the main page only. I don't understand the following code:

if ($this_is_home_page) {
include('top_main.php');
}
else
{
include('top.php');
}

Just cut and past this code to the main index?? Please help...I'm new at this and really don't no how to implement this. Thanks

31 Mar 2008, 10:34 AM
#11
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Different header/footer on home page only.

top_main.php
is shown on home page only and contains
your flash code
top2.php
is shown on all other pages and contains
normal header code i.e. non flash
add code coloured red to
/includes/templates/namofyourcurrenttemplate/common/ tpl_header.php
as follows

<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>
<?php
if ($this_is_home_page) {
include('top_main.php');
}
else
{
include('top2.php');
}
?>
3 Nov 2008, 1:23 PM
#12
bcaa8ra avatar

bcaa8ra

New Zenner

Join Date:
Jan 2008
Posts:
5
Plugin Contributions:
0

Re: Different header/footer on home page only.

chrispopovic, In case you are still working on the flash playing only once then what you need to do is add a small bit of action script to the flash file.
a. Look for a cookie
b. play movie if cookie not st
c. set a cookie.

Here is a sample I have in a flash file that works.


myreplay = SharedObject.getLocal("kookie");

if (myreplay.data.name == undefined){
gotoAndPlay(2);
myreplay.data.name = "beenplayed";
} else {
gotoAndPlay(70);
}


Bernie
Sarasota Web Design - MakoWeb.com

9 Feb 2009, 11:19 AM
#13
zaid avatar

zaid

New Zenner

Join Date:
Dec 2008
Posts:
6
Plugin Contributions:
0

Re: Different header/footer on home page only.

I have a similar qusetion
I want to completely remove the header and footer out of my contact_us page only, or to be more specific: my "ask a question" page.

Reason being is because I am having that page load in an Iframe and I would rather have it not have the entire page (header, footer, main content, sideboxes etc) in the Iframe. I just want to get the body of the contact us page. Basically just the form.

Would I do it sort of the same way you guys have explained here?

Maybe use a

if ($this_is_contact_us_page) {

statement or something like that?

9 Feb 2009, 11:24 AM
#14
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Different header/footer on home page only.

zaid:

I want to completely remove the header and footer out of my contact_us page onlySuppressing them's a bit different. Take a look at the you of your includes/template/YOUR_TEMPLATE/common/tpl_main_page.php for an explanation (if you haven't got a file called that, make a copy from the template_default equivalent).

9 Feb 2009, 7:57 PM
#15
zaid avatar

zaid

New Zenner

Join Date:
Dec 2008
Posts:
6
Plugin Contributions:
0

Re: Different header/footer on home page only.

hmmm i seem to be having a problem figuring it out.

any tips?

I will continue to try but just letting ya know

10 Feb 2009, 4:04 AM
#16
zaid avatar

zaid

New Zenner

Join Date:
Dec 2008
Posts:
6
Plugin Contributions:
0

Re: Different header/footer on home page only.

woot i got it

<div id="askQuestion" class="biggerText"> <?php echo '<iframe name ="ifram1" height="700" width="100%" scrolling ="no" frameborder="no" src="' . zen_href_link(FILENAME_ASK_A_QUESTION, 'products_id=' . $_GET['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_ASK_A_QUESTION, BUTTON_ASK_A_QUESTION_ALT) . '</iframe>'; ?></div> <br /> <br class="clearBoth" />
  • creating a folder named ask_a_question with the file tpl_main_page.php

then in that file putting

$flag_disable_header = true;
$flag_disable_left = true;
$flag_disable_right = true;
$flag_disable_footer = true;

FTW FTW! love these forums :)

17 Feb 2009, 6:07 AM
#17
jhouse avatar

jhouse

Zen Follower

Join Date:
Dec 2006
Posts:
132
Plugin Contributions:
0

Re: Different header/footer on home page only.

misty:

top_main.php
is shown on home page only and contains
your flash code
top2.php
is shown on all other pages and contains
normal header code i.e. non flash
add code coloured red to
/includes/templates/namofyourcurrenttemplate/common/ tpl_header.php
as follows

<?php if (!isset($flag_disable_header) || !$flag_disable_header) { ?>

<?php if ($this_is_home_page) { include('top_main.php'); } else { include('top2.php'); } ?>


Thank you Misty, this worked perfectly.
17 Feb 2009, 8:38 AM
#18
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Different header/footer on home page only.

JHouse:

Thank you Misty, this worked perfectly.
Pleased to hear mission accomplished
:clap:

18 Feb 2009, 6:34 AM
#19
jhouse avatar

jhouse

Zen Follower

Join Date:
Dec 2006
Posts:
132
Plugin Contributions:
0

Re: Different header/footer on home page only.

Yes, yes it was a success. I was dreading trying to pull it all off, but with your advice, it worked like a charm. Felt good!

On a related note, do you know if it's possible to apply this same concept to category and sub-category pages? For instance, on my client's site they have multiple sub-categories such as Cookies, Muffins, Brownies, etc. It would be awesome to have just cookies in the header when viewing the Cookies category, then just muffins in the header when viewing the Muffins category. Any ideas?

Thanks.

18 Feb 2009, 6:37 AM
#20
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Different header/footer on home page only.

On a related note, do you know if it's possible to apply this same concept to category
Yes, but would need to see site in question before explaining
how it is achieved..depends on template being used...re coding.