Forums / Templates, Stylesheets, Page Layout / using an include for a header

using an include for a header

Locked
Results 1 to 9 of 9
This thread is locked. New replies are disabled.
17 Aug 2006, 04:23
#1
jford avatar

jford

Zen Follower

Join Date:
Mar 2006
Posts:
162
Plugin Contributions:
0

using an include for a header

I want to use an include to pull in some html from another file to use as a header, while turning off the current header. i don't want to have to make one big image and rebuild links, just pull in code from a file i call store_banner.html. i was able to do this in 1.2.7, but have been unsuccessful in 1.3. can anyone help?
17 Aug 2006, 04:29
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: using an include for a header

I don't know exactly what you have as you did not post the code, but you should be able to insert straight html into tpl_header.php just outside of the php tags.
17 Aug 2006, 05:15
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: using an include for a header

In 1.3, if you want to skip the main header altogether, and replace it with something else for ALL pages on your site, you have 2 options:

1. edit the includes/templates/YOURTEMPLATE/common/tpl_header.php
and replace its contents with your custom content

or

2. edit includes/templates/YOURTEMPLATE/common/tpl_main_page.php
and change line 47:[PHP] $header_template = 'tpl_header.php';
[/PHP]to point to an alternate file located in your template's "common" folder (same place where tpl_header.php and tpl_main_page.php for your template are located)
02 Nov 2006, 13:46
#4
markov avatar

markov

New Zenner

Join Date:
Sep 2006
Posts:
32
Plugin Contributions:
0

Re: using an include for a header

Hi DrByte,
I am having a bit of a problem with this.
I have created a template, created a common folder, copied across the tpl_main_page.php and tpl_header.php to the common folder - and edited line 47 of tpl_main_page.php to read

$header_template = 'seating.php';

seating.php has also been placed in the common folder. It is a simple sliced header image with links. All the images are placed in an images folder placed within the common folder for simplicity. It could be called seating.html as it is pure html - I have tried calling it seating.html as well as seating.php - but nothing seems to be changing and my page header remains unchanged.

Am I missing something? Does something else need to be switched before I see my header?

I am using 1.35, my site is purely a showcase site and my template is a copy of Classic Contemporary Green.
02 Nov 2006, 22:52
#5
markov avatar

markov

New Zenner

Join Date:
Sep 2006
Posts:
32
Plugin Contributions:
0

Re: using an include for a header

Ok - I still couldn't get the header to display using your tpl_main_page.php method - so I may be doing something wrong there? If anyone can point out what may be wrong here - please jump in.

However - using the first method of adding code to the tpl_header.php works fine. If anybody is struggling here due to lack of php skills or coffee - this is how I did it.

In my case I have a Showcase website - I don't need logins or cart features. I used Dreamweaver and Fireworks to quickly create my custom header with slices and html links. By using the Firefox "Web Developer" extension - I can see that my header background image is in a div called #logoWrapper.

I then set the height of this div to be the same height of my newly sliced html table from Dreamweaver. I then went to tpl_header.php in my custom/common folder and looked for the #logoWrapper div.

I then placed my table straight after <div id="logoWrapper"> make sure it is placed here - not above this div or within any other div inside this div.

All the images for this table were placed in my root/images folder

And it worked fine. The table appeared and was perfect.

Note that I had also turned off the EZ-Pages Display Status - HeaderBar under Configuration>EZ Pages Settings and I had earlier removed the whole of the div containg the header wrapper (<div id="headerWrapper">) down to<!--eof-navigation display-->
I did this because the Home link kept appearing.

This seemed to work for me. Of course once it is working and you have the Client of your back and time on your hands, you can recode your table to be a nice CSS set of divs - following Kuroi's advice in this thread.

http://www.zen-cart.com/forum/showthread.php?t=34474
03 Nov 2006, 04:58
#6
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Posts:
1,156
Plugin Contributions:
0

Re: using an include for a header

1st, for the using of
tpl_header.php

markov:

However - using the first method of adding code to the tpl_header.php works fine. If anybody is struggling here due to lack of php skills or coffee - this is how I did it.

It can be simplified.
For your example the target file you want it to be inserted,
seat.php (or seat.htm)

Then in your override file of tpl_header.php, and in the appropriate location, insert one line and as the example below.

<?php include 'seat.php' ?>


Then the seat.htm will be inserted to the related location inside the header.

For the other functions don't wanted in the original header, just remark out them. Or your new override tpl_header.php can only contain the one line in above example.


2nd, for the using of
tpl_main_page.php

Please note that in the begin of the file, it have the variables defined
  $header_template = 'seating.php';
  $footer_template = 'tpl_footer.php';
  $left_column_file = 'column_left.php';
  $right_column_file = 'column_right.php';


However, the code followed still use the tpl_header.php, instead of the variable $header_template. Hence, your file don't has the chance.

To solve this, in your override file of tpl_main_page.php
find the line below at about line #70
[php] require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>[/php]

And change it to use the variable $header_template instead of the tpl_header.php
[php] require($template->get_template_dir($header_template ,DIR_WS_TEMPLATE, $current_page_base,'common'). '/' . $header_template);?>[/php]

And for the other three variables, repeat the steps above for each variable.

.
04 Nov 2006, 21:09
#7
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: using an include for a header

I have created a template, created a common folder, copied across the tpl_main_page.php and tpl_header.php to the common folder - and edited line 47 of tpl_main_page.php to read

When you did this did you copy and edit the template_info.php file to the "new template" folder with a name for your created template?
If so, did you activate it in the admin > tools > template selection area?
06 Nov 2006, 05:07
#8
markov avatar

markov

New Zenner

Join Date:
Sep 2006
Posts:
32
Plugin Contributions:
0

Re: using an include for a header

Hi Kobra and Seethrou

Thanks for the replies - I have decided to revisit this and try again and reset my pages.
Kobra - to answer your question first - yes my updated Template is the one in use. Can I assume that I was indeed correct - or did I miss something in my original post and is Seethrou correct?

Seethrou - thanks for the detailed reply. I liked the look of your initial suggestion - <?php include 'seat.php' ?>. I have played around with this and I can see it calling my page - but where exactly do I need to place this include? I have tried it in a few places - but as I don't understand the main page code - I am only guessing.

I kind of get the second you way you suggest -which is more long-winded
and is really for someone that can read PHP - but it looks like it does the job. Thanks again.
06 Nov 2006, 05:58
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: using an include for a header

markov,

I do not know what your sliced imagery looks like but I normally apply things like this by attaching to various parts of the normal normal page display i.e. headerWrapper, logoWrapper, mainWrapper, or the different parts of the main /center area.

But this can also be controlled and applied via the php files.