Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Sep 2007
    Posts
    12
    Plugin Contributions
    0

    help question Two Separate Header Files

    GOAL: Normal header for my homepage, and a different header for all my other pages.

    FILE: /catalog/includes/templates/custom/common/tpl_main_page.php

    NOTES: If the index page is displayed, then display the tpl_header.php file. Otherwise, display the tpl_header2.php file.

    CODE SO FAR (that doesn't work):
    Code:
    <div id="mainWrapper">
    <?php
     /**
      * prepares and displays header output
      *
      */
      if ($current_page_base == 'index') {
      require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');?>
      <div class="dt cont_main"  style="background:#FFFFFF">
    						<div class="dr">
    							<div class="dc cont_main_c1"><br style="line-height:2px;">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="contentMainWrapper">
      <tr>
      <?php }
      else {
      require($template->get_template_dir('tpl_header2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header2.php');?>
      <div class="dt cont_main"  style="background:#FFFFFF">
    						<div class="dr">
    							<div class="dc cont_main_c1"><br style="line-height:2px;">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" id="contentMainWrapper">
      <tr>
      }?>
    ERROR MESSAGE:
    Parse error: syntax error, unexpected $end in /home/domain/public_html/catalog/includes/templates/custom/common/tpl_main_page.php on line 198

    Line 198 is basically the bottom of the php file.

    I may be going about this the hard way...I'd appreciate any assistance.

  2. #2
    Join Date
    Sep 2007
    Posts
    12
    Plugin Contributions
    0

    Idea or Suggestion Re: Two Separate Header Files

    I have refined the code, but still the same problem:

    Code:
    <div id="mainWrapper">
    <?php
     /**
      * prepares and displays header output
      *
      */
      if ($current_page_base == 'index') {
      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');?>

  3. #3
    Join Date
    Sep 2007
    Posts
    12
    Plugin Contributions
    0

    Idea or Suggestion Re: Two Separate Header Files

    With less than a minute of testing, this seems to work perfectly:

    Code:
      if ($current_page_base == 'index') {
      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'); }?>
    PROBLEM SOLVED! (or so I hope )

  4. #4
    Join Date
    Jul 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Two Separate Header Files

    Hi there

    This doesn't work for me.

    In my version of Zen-Cart, every page is reference by way of
    /index.php?main_page=index

    for example, category page URL: http://mysite.com/shop/index.php?mai...=index&cPath=7

    So this solution doesn't do it for me...I'm also looking for implementing 2 different headers.

    I might have to test the URL for additional parameters, if they're present we kick in the other header. If no parameter is there but main_page=..., then we know for sure we are looking at the index page.

    I'll be digging the forums a bit more...

    Cheers.
    Jonathan

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

    Default Re: Two Separate Header Files

    This doesn't work for me.
    OK...What page(es) do you want different?

    Direct links to your pages would be helpful
    Zen-Venom Get Bitten

  6. #6
    Join Date
    Jul 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Two Separate Header Files

    Ok I found how to do this:

    this will test if there is more than one query in the URL. If only one query, then we know we're in the homepage...

    if (sizeof($_GET) == 1 ) { #that's if we're in the homepage
    require($template->get_template_dir('tpl_headerHome.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_headerHome.php'); }

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

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

    Default Re: Two Separate Header Files

    If only for main page - look at tpl_main_page.php and find
    Code:
    $body_id = ($this_is_home_page) ? 'indexHome' : str_replace('_', '', $_GET['main_page']);
    Zen-Venom Get Bitten

  8. #8
    Join Date
    Oct 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Two Separate Header Files

    Is there a way to combine these 2 functions. The first one works for my pages outside of the shopping pages (e.g. "index.php?main_page=photos"), and the latter works with my "zen-generated" pages with more than 1 query.

    There should be a way to say "if the current page is 'index' AND if there is only one query, then show headerHome.php"

    Any ideas?

  9. #9
    Join Date
    Oct 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Two Separate Header Files

    Nevermind. I got it using kobra's suggestion. I didn't get what he was saying at first.

    Thanks kobra!!!

  10. #10
    Join Date
    Oct 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Two Separate Header Files

    Spoke too soon. I screwed up the home page.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Two Separate Checkouts?
    By AaronHicks in forum Managing Customers and Orders
    Replies: 2
    Last Post: 11 Aug 2011, 06:33 AM
  2. Can Two Separate Products Share Same Inventory?
    By Jeff_Mash in forum General Questions
    Replies: 3
    Last Post: 14 Jan 2009, 10:52 PM
  3. Two currencies with separate shipping rates?
    By kylelondonuk in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 6
    Last Post: 11 Jul 2007, 08:54 AM
  4. CSS Flyout Menu - separate to two main categories
    By TomCZ in forum General Questions
    Replies: 0
    Last Post: 17 Mar 2007, 08:07 PM
  5. Two separate classes for hyperlinks
    By DJBobble in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 Sep 2006, 11:30 AM

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