Zen Cart – Change the template design on the home page only

Here’s a little one I found that might simplify things for you. I wanted to override the homepage template on the index page of a zen cart powered website, basically so I could show a big ad type image on the homepage under the navigation, so that it would appear on teh homepage only, like a big call to action / visual impact to start the visitors journey off. I needed it to load in the top section of the code, rather than the individual content pages so I needed to make the changes in the tpl_main_page.php main page template file.(tpl_main_page.php in your /yourtheme/common/ folder)

I duplicated the header file and made my template adjustments, and then using a bit of php told the site that when it loads, check the pagename – and if the pagename is ‘homepage’ then load the modified headerfile (tpl_header_home.php) – and if it’s anything other than homepage, just load the original.

Anyway, after a bit of fiddling around I found this to work pretty well.

<?php /* ----- prepares and displays header output ----- */

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


Leave a Reply

Your email address will not be published. Required fields are marked *