Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2006
    Posts
    163
    Plugin Contributions
    0

    Default 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?

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default 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.
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default 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 Code:
      $header_template 'tpl_header.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)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Sep 2006
    Posts
    32
    Plugin Contributions
    0

    Default 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.

  5. #5
    Join Date
    Sep 2006
    Posts
    32
    Plugin Contributions
    0

    Default 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

  6. #6
    Join Date
    May 2004
    Location
    Hong Kong
    Posts
    1,291
    Plugin Contributions
    1

    Default Re: using an include for a header

    1st, for the using of
    tpl_header.php

    Quote Originally Posted by markov View Post
    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.

    Code:
    <?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
    Code:
      $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 Code:
      require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE$current_page_base,'common'). '/tpl_header.php');?> 
    And change it to use the variable $header_template instead of the tpl_header.php
    PHP Code:
      require($template->get_template_dir($header_template ,DIR_WS_TEMPLATE$current_page_base,'common'). '/' $header_template);?> 
    And for the other three variables, repeat the steps above for each variable.

    .
    A New Starter again

  7. #7
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default 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?
    Zen-Venom Get Bitten

  8. #8
    Join Date
    Sep 2006
    Posts
    32
    Plugin Contributions
    0

    Default 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.

  9. #9
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default 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.
    Zen-Venom Get Bitten

 

 

Similar Threads

  1. using PHP include statements
    By JayC in forum General Questions
    Replies: 3
    Last Post: 10 Sep 2011, 11:27 PM
  2. How to include define_page_2.php content in header for easy editing
    By vandiermen in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 30 May 2009, 07:56 PM
  3. Using include in product description
    By jeking in forum Templates, Stylesheets, Page Layout
    Replies: 42
    Last Post: 30 Jan 2008, 06:15 AM
  4. Using php include in product descriptions
    By gaekwad in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 12 Jun 2007, 11:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR