Jump to content
Sign in to follow this  
bpmcclure

Main Categories on Main Page

Recommended Posts

As Topic Description notes I have the Main Categories on Main Page contribution (uses main_categories.php in catalog/includes/modules) installed and it works fine in my local development environment. I have deployed the store to a live server, and the site works fine except the category boxes no longer show up on the index page. I'm stumped and looking for some ideas on where to start troubleshooting this.

 

Thanks,

 

Bruce

Edited by bpmcclure

Share this post


Link to post
Share on other sites
I'm stumped and looking for some ideas on where to start troubleshooting this.

 

Always start troubleshooting by checking your error logs for php errors. Set your php.ini display_errors option to display all errors, load the page, and then check your logs. If you have already done this and are not seeing any errors, I would suggest posting a link to your domain for others to look at the source code.

Share this post


Link to post
Share on other sites
Always start troubleshooting by checking your error logs for php errors. Set your php.ini display_errors option to display all errors, load the page, and then check your logs. If you have already done this and are not seeing any errors, I would suggest posting a link to your domain for others to look at the source code.

 

I turned on error reporting in the application_top.php file (I knew how to do that one!), and oddly I get different errors in the dev site and the live one. I think the problem is related to these errors, which show up on the index page in the production site:

 

Notice: Use of undefined constant php - assumed 'php' in /home/supper5/public_html/os/includes/modules/main_categories.php on line 1

 

Notice: Use of undefined constant php - assumed 'php' in /home/supper5/public_html/os/includes/modules/main_categories.php on line 1

 

Clearly php is not a variable, it is the code tag at the very beginning of the file. Here is the code in that file:

 

<?php/*  $Id: main_categories.php,v 1.0a 2002/08/01 10:37:00 Exp $  osCommerce, Open Source E-Commerce Solutions  [url="http://www.oscommerce.com/"]http://www.oscommerce.com/[/url]  Copyright © 2002 Barreto  Gustavo Barreto <gustavo@barreto.net>  [url="http://www.barreto.net/"]http://www.barreto.net/[/url]  Based on: all_categories.php Ver. 1.6 by Christian Lescuyer  History: 1.0 Creation	   1.0a Correction: Extra Carriage Returns	   1.1  added parameters to change display options -- mdt  Released under the GNU General Public License*///------------------------------------------------------------------------------------------------------// PARAMETERS//------------------------------------------------------------------------------------------------------$item_column_number = 2;		// range of 1 to 9$item_title_on_newline = true;	// true or false$valign = middle;	                  // middle, top, or bottom (determines the vertical placement of the images)$hover = on;                        // turns hover effect on or off// The Following Parameters are for customizing the hover effect// leave the # in the color values or the border may not show$hovercolor = "#006699";            // color for category when the mouse hovers over it$hoverborder = "#FFCC66";           // color for category border when hovered (ignore if $borderwidth is set to 0)$regcolor = "#FFCC66";              // color for category when not hovered$regborder = "#006699";             // color for category border when not hovered (ignore if $borderwidth is set to 0)$borderwidth = 3;                   // width of border around categories (in pixels, 0 for none)// for item and subcategory options, suugest that you just put in CSS code// you can also just define a class and then change it in a template addon like BTS$item_div_options = 'style="text-align:center;font-weight:bold;font-size:larger;margin-top:5px;margin-bottom:5px;"';$item_subcategories_options = '';//------------------------------------------------------------------------------------------------------// CODE - do not change below here//------------------------------------------------------------------------------------------------------// error checking on parametersif($item_column_number < 1){	$item_column_number = 1;}if($item_column_number > 9){	$item_column_number = 9;}if($item_title_on_newline){	$item_separator = '<br>';} else {	$item_separator = ' ';}// Preorder tree traversal  function preorder($cid, $level, $foo, $cpath)  {    global $categories_string, $HTTP_GET_VARS;// Display link    if ($cid != 0) {      for ($i=0; $i<$level; $i++)        $categories_string .=  '  ';      $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cpath . $cid) . '">';// 1.6 Are we on the "path" to selected category?      $bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid;// 1.6 If yes, use <b>      if ($bold)        $categories_string .=  '<b>';      $categories_string .=  $foo[$cid]['name'];      if ($bold)        $categories_string .=  '</b>';      $categories_string .=  '</a>';// 1.4 SHOW_COUNTS is 'true' or 'false', not true or false      if (SHOW_COUNTS == 'false') {        $products_in_category = tep_count_products_in_category($cid);        if ($products_in_category > 0) {          $categories_string .= ' (' . $products_in_category . ')';        }      }      $categories_string .= '<br>';    }// Traverse category tree    if (is_array($foo)) {      foreach ($foo as $key => $value) {        if ($foo[$key]['parent'] == $cid) {          preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : ''));        }      }    }  }?><!-- main_categories //-->          <tr>            <td><?php//////////// Display box heading//////////  $info_box_contents = array();  $info_box_contents[] = array('align' => 'left', 'text'  => BOX_HEADING_CATEGORIES);  new infoBoxHeading($info_box_contents, false, false);//////////// Get categories list//////////// 1.2 Test for presence of status field for compatibility with older versions  $status = tep_db_num_rows(tep_db_query('describe categories status'));  $query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image            from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION ." cd            where c.categories_id = cd.categories_id";// 1.3 Can't have 'where' in an if statement!  if ($status >0)    $query.= " and c.status = '1'";  $query.= " and cd.language_id='" . $languages_id ."'            order by sort_order, cd.categories_name";  $categories_query = tep_db_query($query);// Initiate tree traverse$categories_string = '';preorder(0, 0, $foo, '');//////////// Display box contents//////////$info_box_contents = array();$row = 0;$col = 0;while ($categories = tep_db_fetch_array($categories_query)){	if ($categories['parent_id'] == 0)   	{   		$cPath_new = tep_get_path($categories['categories_id']);    /*"OMITED SO IT DOESNT DISPLAY SUBCATEGORIES"	$text_subcategories = '';    	$subcategories_query = tep_db_query($query);    	while ($subcategories = tep_db_fetch_array($subcategories_query))*/    	{     		if ($subcategories['parent_id'] == $categories['categories_id']) 			{                $cPath_new_sub = "cPath="  . $categories['categories_id']/*"OMITED SO IT DOESNT DISPLAY SUBCATEGORIES" . "_" . $subcategories['categories_id']*/;                $text_subcategories .= '� <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">';                $text_subcategories .= $subcategories['categories_name'] . '</a>' . " ";                        	} // if ($subcategories['parent_id'] == $categories['categories_id'])    	} // while ($subcategories = tep_db_fetch_array($subcategories_query))		if ($hover == 'on'){		$info_box_contents[$row][$col] = array('align' => 'left',                                           'params' => 'class="smallText" style="border:' . $borderwidth . 'px solid ' . $regborder . '" onMouseOver="window.status=\'' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '\'; this.style.backgroundColor=\'' . $hovercolor . '\'; this.style.cursor=\'hand\'; this.style.border=\'' . $borderwidth . 'px solid ' . $hoverborder . '\';" onMouseOut="window.status=\'\'; this.style.backgroundColor=\'' . $regcolor . '\'; this.style.border=\'' . $borderwidth . 'px solid ' . $regborder . '\';" onclick="location.href=\'' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '\'" width="'.intval(100/$item_column_number).'%" valign="' . $valign . '"',                                           'text' => '<div '. $item_div_options . '><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' .  tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>' . $item_separator . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . $categories['categories_name'] . '</a><DIV ' . $item_subcategories_options . '>' . $text_subcategories . $spacing . '</DIV></DIV>');}else{		$info_box_contents[$row][$col] = array('align' => 'left',                                           'params' => 'class="smallText" width="'.intval(100/$item_column_number).'%" valign="' . $valign . '"',                                           'text' => '<div '. $item_div_options . '><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' .  tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>' . $item_separator . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . $categories['categories_name'] . '</a><DIV ' . $item_subcategories_options . '>' . $text_subcategories . '</DIV></DIV>');}        	// determine the column position to see if we need to go to a new row    	$col ++;    	if ($col > ($item_column_number - 1))    	{      		$col = 0;      		$row ++;      		    	} //if ($col > ($number_of_columns - 1))    	    } //if ($categories['parent_id'] == 0)} // while ($categories = tep_db_fetch_array($categories_query))//output the contentsnew contentBox($info_box_contents);?>            </td>          </tr><!-- main_categories_eof //-->

 

The file seems to have been corrupted as it all shows on a single line. I ultimately uploaded a new copy of this file from the contribution, and all seem OK now. Thank for the pointer!

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×