Page 1 of 1

Newbie need help with simple code insertion

Posted: Thu Oct 14, 2010 5:44 pm
by verygreen
Hi everyone,

Im not really a programmer so I don't really know if this is the place for me but I am designing a website and using a lot of PHP files and templates.

I have this file tpL_header.php and I installed a feature the requires me to insert a piece of code into that file. I have no idea where to put the code, when I try my page either doesnt load
or it only loads upto that piece of code and cuts off the rest.

I dont even know if its possible for anyone to comment since you cant see all my files but at least from a syntax point of view I would like a recommendation of where
would be logical to insert it to get some results.

Please dont laught at me im only new to this :D :roll:

Thank You

CODE 1 is the PHP file, CODE 2 is the code i need to insert

CODE 1:

Code: Select all

<?php
/**
 * 		
 *				<!-- ====================================== -->
 *			</div>
 *			<div class="currency-form">
 *				<!-- ========== CURRENCIES ========= --><div></div>
 *
 *
 *
 *
 *
 * Common Template - tpl_header.php
 *
 * this file can be copied to /templates/your_template_dir/pagename<br />
 * example: to override the privacy page<br />
 * make a directory /templates/my_template/privacy<br />
 * copy /templates/templates_defaults/common/tpl_footer.php to /templates/my_template/privacy/tpl_header.php<br />
 * to override the global settings and turn off the footer un-comment the following line:<br />
 * <br />
 * $flag_disable_header = true;<br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_header.php 4813 2006-10-23 02:13:53Z drbyte $
 */
?>

<?php
  // Display all header alerts via messageStack:
  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
  if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) {
  echo htmlspecialchars(urldecode($_GET['error_message']));
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message']);
} else {

}
?>


<!--bof-header logo and navigation display-->
<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>


<script type="text/javascript">
	jQuery(window).bind("load", function() { 
	jQuery("div#mygalone").slideView(); 
	
		var slider_links = jQuery('.stripTransmitter li a');				
		var slider_links_index = 0;		
		function slider_intro(){						
			slider_links.eq(slider_links_index).trigger('click');			
			slider_links_index++;			
			if(slider_links_index <= slider_links.size()){
				setTimeout(function(){slider_intro()}, 500000); //select change time
			}
			else if(slider_links_index > slider_links.size()){				
				slider_links.eq(0).trigger('click')
			}			
		}		
		slider_intro();
	
	
}); 
</script>


<div id="header">
	<div class="top">
		<div class="logo">
			<!-- ========== LOGO ========== -->
				<a href="<?php echo zen_href_link(FILENAME_DEFAULT);?>"><?php echo zen_image(DIR_WS_TEMPLATE.'images/logo.gif'); ?></a>
			<!-- ========================== -->
		</div>
		<div class="fright alignright">
			<div class="nav-links">
				<!-- ========== NAVIGATION LINKS ========== -->
					<?php echo zen_draw_form('currencies', zen_href_link(basename(ereg_replace('.php','', $PHP_SELF)), '', $request_type, false), 'get');?>
				<?php echo BOX_HEADING_CURRENCIES; ?>:&nbsp;
				<?										
					if (isset($currencies) && is_object($currencies)) {						
					  reset($currencies->currencies);
					  $currencies_array = array();
					  while (list($key, $value) = each($currencies->currencies)) {
						$currencies_array[] = array('id' => $key, 'text' => $value['title']);
					  }										
					  $hidden_get_variables = '';
					  reset($_GET);
					  while (list($key, $value) = each($_GET)) {
						if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) {
						  $hidden_get_variables .= zen_draw_hidden_field($key, $value);
						}
					  }
					}										
				?><?php echo zen_draw_pull_down_menu('currency', $currencies_array, $_SESSION['currency'], ' onchange="this.form.submit();"') . $hidden_get_variables . zen_hide_session_id();?>
				
&nbsp; | &nbsp;  

<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a>
				<?php if ($_SESSION['customer_id']) { ?>
					&nbsp; | &nbsp; <a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a>
					&nbsp; | &nbsp; <a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>
				<?php
					  } else {
						if (STORE_STATUS == '0') {
				?>
					&nbsp; | &nbsp; <a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a>
				<?php } } ?>

				<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
					&nbsp; | &nbsp; <a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a>
				<?php }?>		
		
				</form>	
				
				<!-- ====================================== -->
			</div>
			<div class="lang">
				<!-- ========== LANGUAGES ========== -->
				<?php if (!isset($lng) || (isset($lng) && !is_object($lng))) {
					$lng = new language;
				  }

				  reset($lng->catalog_languages);

				  while (list($key, $value) = each($lng->catalog_languages)) {
					echo '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . zen_image(DIR_WS_LANGUAGES.$value['directory'].'/images/'.$value['image'], $value['name'], '', '', ' style="vertical-align:middle;"') . '</a>';
				  }
				 ?>				
				<!-- =============================== -->
			</div>
			<div class="cart">
				<!-- ========== SHOPPING CART ========== -->
				<?php 
					if ($_SESSION['cart']->count_contents() == 1) {
						$items = $_SESSION['cart']->count_contents() . ' item';
					} else {
						$items = $_SESSION['cart']->count_contents() . ' items';
					}
				?>  
				<strong><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL');?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></strong>: now in your cart <a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL');?>"><?php echo $items;?></a>
				<!-- =================================== -->
			</div>
		</div>
	</div>
	<div class="wrapper">
		<!-- ========== MENU ========== -->
			<div class="menu">
				<!--bof-header ezpage links-->
				<?php if (EZPAGES_STATUS_HEADER == '1' or (EZPAGES_STATUS_HEADER == '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])))) { ?>
				<?php require($template->get_template_dir('tpl_ezpages_bar_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ezpages_bar_header.php'); ?>
				<?php } ?>
				<!--eof-header ezpage links-->			
			</div>
		<!-- ========================== -->
		<div class="search-form">
			<!-- ========== SEARCH ========== -->
				<?php require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_search_header.php');?>   
			<!-- ============================ -->
		</div>
	</div>
	




<!-- ========CAROUSEL======= -->

<!-- <?php require($template->get_template_dir('tpl_slider.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_slider.php');?> -->
	
 			
	
<?php } ?>
CODE 2:

Code: Select all

<?php require($template->get_template_dir('tpl_drop_menu.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_drop_menu.php');?>
<!--eof-drop down menu display-->
<div class="clearBoth"></div>

Re: Newbie need help with simple code insertion

Posted: Thu Oct 14, 2010 7:16 pm
by Jonah Bron
Hehe. This might sound like a silly question, but where does it belong? It looks like it generates a drop down menu, so where is a drop down menu supposed to go in your page?

Re: Newbie need help with simple code insertion

Posted: Thu Oct 14, 2010 7:22 pm
by verygreen
Yes thats right thats exactly what it does. The dropdown menu would go on the top of my page www.majesticsilver.co.uk/store.
I downloaded all the PHP files and placed them correctly in my shopping cart folders. All it says in the install is to insert the code in the tpl_header.php file
but it doesnt say where, and as with all free open source things support is hard to come by so in my desperation ive joined a programming forum :roll:

For your interest I am attaching the original tpl_header.php file from the creator of that mod im trying to install, its nothing like my one but maybe to the trained eye it would look similar.
I need to take all the features from my one and just add that code, but perhaps there is more to it... Im going a lil bit :crazy:
Any ideas whatsoever would be most welcome! :D

Code: Select all

<?php
/**
 * Common Template - tpl_header.php
 *
 * this file can be copied to /templates/your_template_dir/pagename<br />
 * example: to override the privacy page<br />
 * make a directory /templates/my_template/privacy<br />
 * copy /templates/templates_defaults/common/tpl_footer.php to /templates/my_template/privacy/tpl_header.php<br />
 * to override the global settings and turn off the footer un-comment the following line:<br />
 * <br />
 * $flag_disable_header = true;<br />
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_header.php 3392 2006-04-08 15:17:37Z birdbrain $
 */
?>
<?php
  // Display all header alerts via messageStack:
  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
  if (isset($_GET['error_message']) && zen_not_null($_GET['error_message'])) {
  echo htmlspecialchars(urldecode($_GET['error_message']));
  }
  if (isset($_GET['info_message']) && zen_not_null($_GET['info_message'])) {
   echo htmlspecialchars($_GET['info_message']);
} else {

}
?>
<!--bof-header logo and navigation display-->
<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>
<div id="headerWrapper">
  <!--bof-navigation display-->
  <div id="navMainWrapper">
    <div id="navMain">
      <div id="navMainLinks">
        <ul class="back">
          <li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>
          <?php if ($_SESSION['customer_id']) { ?>
          <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
          <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
          <?php
      } else {
        if (STORE_STATUS == '0') {
?>
          <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
          <?php } } ?>
          <?php if ($_SESSION['cart']->count_contents() != 0) { ?>
          <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
          <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
          <?php }?>
        </ul>
      </div>
      <div id="navMainSearch">
        <?php require(DIR_WS_MODULES . 'sideboxes/search_header.php'); ?>
      </div>
    </div>
  </div>
  <div class="clearBoth"></div>
  <!--eof-navigation display-->
  <!--bof-branding display-->
  <div id="logoWrapperOuter">
    <div id="logoWrapper">
      <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT, HEADER_LOGO_WIDTH, HEADER_LOGO_HEIGHT) . '</a>'; ?></div>
      <?php if (HEADER_SALES_TEXT != '' || (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2))) { ?>
      <div id="taglineWrapper">
        <?php
              if (HEADER_SALES_TEXT != '') {
?>
        <div id="tagline"><?php echo HEADER_SALES_TEXT;?></div>
        <?php
              }
?>
        <?php
              if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) {
                if ($banner->RecordCount() > 0) {
?>
        <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div>
        <?php
                }
              }
?>
      </div>
      <?php } // no HEADER_SALES_TEXT or SHOW_BANNERS_GROUP_SET2 ?>
    </div>
  </div>
</div>
<div class="clearBoth"></div>
<!--eof-branding display-->
<!--eof-header logo and navigation display-->
<!--bof-header ezpage links-->
<?php if (EZPAGES_STATUS_HEADER == '1' or (EZPAGES_STATUS_HEADER == '2' and (strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])))) { ?>
<?php require($template->get_template_dir('tpl_ezpages_bar_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_ezpages_bar_header.php'); ?>
<?php } ?>
<!--eof-header ezpage links-->
<!--bof-optional categories tabs navigation display-->
<?php require($template->get_template_dir('tpl_modules_categories_tabs.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_categories_tabs.php'); ?>
<!--eof-optional categories tabs navigation display-->
<!--bof-drop down menu display-->
<?php require($template->get_template_dir('tpl_drop_menu.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_drop_menu.php');?>
<!--eof-drop down menu display-->
<div class="clearBoth"></div>
<?php } ?>