Jump to content

Archived

This topic is now archived and is closed to further replies.

Snowman

Help: Category Name instead of "Lets see what we have h

Recommended Posts

Im working on a new snapshot upgrading a store from an early March snapshot, and i want to display the category names on each category and sub category instead of "Lets see what we have here"

 

I noticed in the old default.php file in the languages/english directory that i had :

 

if (isset($current_category_name)) define('HEADING_TITLE', $current_category_name);

else define('HEADING_TITLE', 'Products');

 

However the new language file only has:

 

define('HEADING_TITLE', 'Let's See What We Have Here');

 

what do i need to do to bring this functionality back to my categories???

 

[/code]

Share this post


Link to post
Share on other sites
I noticed in the old default.php file in the languages/english directory that i had :

 

if (isset($current_category_name)) define('HEADING_TITLE', $current_category_name);

else define('HEADING_TITLE', 'Products');

 

That must be from a contribution - I don't recall that being in CVS.

 

However the new language file only has:

 

define('HEADING_TITLE', 'Let's See What We Have Here');

 

what do i need to do to bring this functionality back to my categories???

 

Try the following function:

 

<?php

 function tep_get_category_name($category_id) {

   global $languages_id;



   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'");

   $category = tep_db_fetch_array($category_query);



   return $category['categories_name'];

 }



 echo tep_get_category_name($current_category_id);

?>

 

That function was taken from tep_get_products_name().

 

Last time I wrote some php logic in the forums, it was written realtime (ie, not tested) so the above logic may not work - but should prove a good guide :)

 

Please post any corrections for others to see.


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Thanks Harald it worked a treat....

 

I added

  function tep_get_category_name($category_id) { 

   global $languages_id; 



   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'"); 

   $category = tep_db_fetch_array($category_query); 



   return $category['categories_name']; 

 }

to the top of default php and then added

  function tep_get_manufacturers_name($manufacturers_id) { 

   global $languages_id; 



   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $manufacturers_id . "'"); 

   $category = tep_db_fetch_array($manufacturers_query); 



   return $manufacturers['manufacturers_name']; 

 }

just before the manufacturers display and changed references of

<?php echo HEADING_TITLE; ?>

to

<?php echo tep_get_category_name($current_category_id);  ?>

and

<?php echo $manufacturers['manufacturers_name'];  ?>

where applicable.

 

Now if im in a category the category name displays or if im browsing by manufacturer the manufacturers name displays instead.

 

Thanks for you help.

Share this post


Link to post
Share on other sites

Hi Steve,

 

That sort of worked but not fully.

The manufacturer heading didn't show up when i selected a manufacturer.

 

Can you please explain in less vague terms where exactly to put this one:

 

<?php echo $manufacturers['manufacturers_name'];  ?>

 

and shouldn't it call the function tep_get_manufacturer_name ??

Ive tried everything but can't figure it out.

 

Please help.

Share this post


Link to post
Share on other sites

ohhh god that was a while ago, im not even sure if the code is the same now....

 

if it is then

 

<?php echo HEADING_TITLE; ?>

 

gets replaced with

 

<?php echo tep_get_category_name($current_category_id);  ?>

 

in the manufacturers section of default.php and all other references to

 

<?php echo HEADING_TITLE; ?>

 

get changed to

 

<?php echo tep_get_category_name($current_category_id);  ?>

 

i think!

Share this post


Link to post
Share on other sites

umm it couldn't be :)

 

that last line should perhaps be something like

 <?php echo  tep_get_manufacturers_name($manufacturers_id???); ?>



Whats the correct variable containing the current manufacturers id?

Share this post


Link to post
Share on other sites

As i said its a long time since i did it and im only guessing, and my code if heavily modded.

 

I'll post my default here as a guide:

 

<?php

/*

 $Id: default.php,v 1.77 2002/07/21 23:38:57 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 require('includes/application_top.php');



// the following cPath references come from application_top.php

 $category_depth = 'top';

 if ($cPath) {

   $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

   $cateqories_products = tep_db_fetch_array($categories_products_query);

   if ($cateqories_products['total'] > 0) {

     $category_depth = 'products'; // display products

   } else {

     $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . $current_category_id . "'");

     $category_parent = tep_db_fetch_array($category_parent_query);

     if ($category_parent['total'] > 0) {

       $category_depth = 'nested'; // navigate through the categories

     } else {

       $category_depth = 'products'; // category has no products, but display the 'no products' message

     }

   }

 }



 function tep_get_category_name($category_id) { 

   global $languages_id; 



   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'"); 

   $category = tep_db_fetch_array($category_query); 



   return $category['categories_name']; 

 } 



 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 

<?php

if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {

 require(DIR_WS_INCLUDES . 'header_tags.php');

} else {

?> 

 <title><?php echo TITLE ?></title>

<?php

}

?>

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<script language="JavaScript" type="text/javascript"> 

<!-- 

window.status="Cart: <?php echo $cart->count_contents(); ?> Items  <?php echo $currencies->format($cart->show_total()); ?>  <?php echo $cart->show_weight() ?>kg(s)" 

// --> 

</script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->



<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

 <tr>

   <td width="<?php echo BOX_WIDTH; ?>" valign="top" rowspan="2"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

   </table></td>

   <td colspan="8">

     <div align="center">

       <center>

       <table border="0" cellpadding="0" cellspacing="0" width="100%">

         <tr>

           <td>

             <div align="center">

               <table border="0" cellpadding="0" cellspacing="0" width="100%">

                 <tr>

           <td class="pageHeading" align="center">

             <p style="word-spacing: 0; line-height: 100%; text-indent: 0; margin: 0"><?php 

 require(DIR_WS_BOXES . 'breadcrumb.php'); 

?></p>

           </td>

                 </tr>

               </table>

             </div>

           </td>

         </tr>

       </table>

       </center>

     </div>

 </tr>

 <tr>

<!-- body_text //-->

<?php

 if ($category_depth == 'nested') {

   $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $current_category_id . "' and cd.categories_id = '" . $current_category_id . "' and cd.language_id = '" . $languages_id . "'");

   $category = tep_db_fetch_array($category_query);

?>

   <td vAlign="top" width="100%">

     <table cellSpacing="0" cellPadding="0" width="100%" border="0">

       <tbody>

         <tr>

           <td>

             <table cellSpacing="0" cellPadding="0" width="100%" border="0">

               <tbody>

                 <tr>

                   <td>

                     <div align="center">

                       <center>

                       <table border="0" cellpadding="1" width="100%" cellspacing="0">

                         <tr>

                           <td width="100%" bgcolor="#800080">

                             <div align="center">

                               <table border="0" cellpadding="4" cellspacing="0" width="100%">

                                 <tr>

                <td width="50" bgcolor="#FFFFFF" class="headerNavigation" style="word-spacing: 0; text-indent: 0; line-height: 100%; margin: 2">Choose category:</td>

                <td class="headerNavigation" bgcolor="#FFFFFF" style="word-spacing: 0; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 3">

<?php

   if ($cPath && ereg('_', $cPath)) {

// check to see if there are deeper categories within the current category

     $category_links = array_reverse($cPath_array);

     for($i=0; $i<sizeof($category_links); $i++) {

       $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . $category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

       if (tep_db_num_rows($categories_query) < 1) {

         // do nothing, go through the loop

       } else {

         break; // we've found the deepest category the customer is in

       }

     }

   } else {

     $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

   }



   $rows = 0;

   while ($categories = tep_db_fetch_array($categories_query)) {

     $rows++;

     $cPath_new = tep_get_path($categories['categories_id']);

     $width = (100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';

     echo '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '"class="headerNavigation">' . $categories['categories_name'] . '</a>, ' . "n";

     if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {

       echo '              </tr>' . "n";

       echo '              <tr>' . "n";

     }

   }

?>

             </td></tr>

            </table>

                             </div>

                           </td>

                         </tr>

                       </table>

                       </center>

                     </div>

                   </td>

                 </tr>



         <tr>

           <td class="pageHeading"><p style="margin-top: 5"><?php echo tep_get_category_name($current_category_id);  ?></p></td>

         </tr>

         <tr>

           <td><br><?php $new_products_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_FEATURED); ?></td>

         </tr>

         <tr>

           <td><br><?php $new_products_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>

         </tr>

       </table></td>

     </tr>

   </table></td>

<?php

 } elseif ($category_depth == 'products' || $HTTP_GET_VARS['manufacturers_id']) {

// create column list

   $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,

                        'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,

                        'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 

                        'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 

                        'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 

                        'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 

                        'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 

                        'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

   asort($define_list);



   $column_list = array();

   reset($define_list);

   while (list($column, $value) = each($define_list)) {

     if ($value) $column_list[] = $column;

   }



   $select_column_list = '';



   for ($col=0; $col<sizeof($column_list); $col++) {

     if ( ($column_list[$col] == 'PRODUCT_LIST_BUY_NOW') || ($column_list[$col] == 'PRODUCT_LIST_PRICE') ) {

       continue;

     }



     if ($select_column_list != '') {

       $select_column_list .= ', ';

     }



     switch ($column_list[$col]) {

       case 'PRODUCT_LIST_MODEL':        $select_column_list .= 'p.products_model';

                                         break;

       case 'PRODUCT_LIST_NAME':         $select_column_list .= 'pd.products_name';

                                         break;

       case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name';

                                         break;

       case 'PRODUCT_LIST_QUANTITY':     $select_column_list .= 'p.products_quantity';

                                         break;

       case 'PRODUCT_LIST_IMAGE':        $select_column_list .= 'p.products_image';

                                         break;

       case 'PRODUCT_LIST_WEIGHT':       $select_column_list .= 'p.products_weight';

                                         break;

     }

   }



   if ($select_column_list != '') {

     $select_column_list .= ', ';

   }



// show the products of a specified manufacturer

   if ($HTTP_GET_VARS['manufacturers_id']) {

     if ($HTTP_GET_VARS['filter_id']) {

// We are asked to show only a specific category

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . $HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . $languages_id . "' and p2c.categories_id = '" . $HTTP_GET_VARS['filter_id'] . "'";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . $HTTP_GET_VARS['manufacturers_id'] . "'";

     }

// We build the categories-dropdown

     $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' and p.manufacturers_id = '" . $HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";

   } else {

// show the products in a given categorie

     if ($HTTP_GET_VARS['filter_id']) {

// We are asked to show only specific catgeory

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . $HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . $languages_id . "' and p2c.categories_id = '" . $current_category_id . "'";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . $languages_id . "' and p2c.categories_id = '" . $current_category_id . "'";

     }

// We build the manufacturers Dropdown

     $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . $current_category_id . "' order by m.manufacturers_name";

   }



   if ( (!$HTTP_GET_VARS['sort']) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'],0,1) > sizeof($column_list)) ) {

     for ($col=0; $col<sizeof($column_list); $col++) {

       if ($column_list[$col] == 'PRODUCT_LIST_NAME') {

         $HTTP_GET_VARS['sort'] = $col+1 . 'a';

         $listing_sql .= " order by pd.products_name";

         break;

       }

     }

   } else {

     $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);

     $sort_order = substr($HTTP_GET_VARS['sort'], 1);

     $listing_sql .= ' order by ';

     switch ($column_list[$sort_col-1]) {

       case 'PRODUCT_LIST_MODEL':        $listing_sql .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

                                         break;

       case 'PRODUCT_LIST_NAME':         $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");

                                         break;

       case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

                                         break;

       case 'PRODUCT_LIST_QUANTITY':     $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

                                         break;

       case 'PRODUCT_LIST_IMAGE':        $listing_sql .= "pd.products_name";

                                         break;

       case 'PRODUCT_LIST_WEIGHT':       $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

                                         break;

       case 'PRODUCT_LIST_PRICE':        $listing_sql .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

                                         break;

     }

   }



 function tep_get_manufacturers_name($manufacturers_id) { 

   global $languages_id; 



   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $manufacturers_id . "'"); 

   $category = tep_db_fetch_array($manufacturers_query); 



   return $manufacturers['manufacturers_name']; 

 } 

?>

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

     <tr>

       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <form>

         <tr>

           <td class="pageHeading"><?php echo $manufacturers['manufacturers_name'];  ?></td>

<?php

// optional Product List Filter

   if (PRODUCT_LIST_FILTER) {

     $filterlist = tep_db_query($filterlist_sql);

     if (tep_db_num_rows($filterlist) > 1) {

       echo '            <td align="center" class="main">' . TEXT_SHOW . '<select size="1" onChange="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">';

       if ($HTTP_GET_VARS['manufacturers_id']) {

         $arguments = 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'];

       } else {

         $arguments = 'cPath=' . $cPath;

       }

       $arguments .= '&sort=' . $HTTP_GET_VARS['sort'];



       $option_url = tep_href_link(FILENAME_DEFAULT, $arguments, 'NONSSL');



       if (!$HTTP_GET_VARS['filter_id']) {

         echo '<option value="' . $option_url . '" SELECTED>' . TEXT_ALL . '</option>';

       } else {

         echo '<option value="' . $option_url . '">' . TEXT_ALL . '</option>';

       }



       echo '<option value="">---------------</option>';

       while ($filterlist_values = tep_db_fetch_array($filterlist)) {

         $option_url = tep_href_link(FILENAME_DEFAULT, $arguments . '&filter_id=' . $filterlist_values['id'], 'NONSSL');

         if ( ($HTTP_GET_VARS['filter_id']) && ($HTTP_GET_VARS['filter_id'] == $filterlist_values['id']) ) {

           echo '<option value="' . $option_url . '" SELECTED>' . $filterlist_values['name'] . '</option>';

         } else {

           echo '<option value="' . $option_url . '">' . $filterlist_values['name'] . '</option>';

         }

       }

       echo '</select></td>' . "n";

     }

   }



// Get the right image for the top-right

   $image = DIR_WS_IMAGES . 'table_background_list.gif';

   if ($HTTP_GET_VARS['manufacturers_id']) {

     $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $HTTP_GET_VARS['manufacturers_id'] . "'");

     $image = tep_db_fetch_array($image);

     $image = $image['manufacturers_image'];

   } elseif ($current_category_id) {

     $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

     $image = tep_db_fetch_array($image);

     $image = $image['categories_image'];

   }

?>

           <td align="right"><?php echo tep_image(DIR_WS_IMAGES . $image, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

         </tr>

         </form>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

     </tr>

     <tr>

       <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>

     </tr>

   </table></td>

<?php

 } else { // default page

?>

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

     <tr>

       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <tr>

           <td class="pageHeading" colspan="3" align="center"></td>

         </tr>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td></td>

     </tr>

     <tr>

       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <tr>

           <td class="main"><?php echo tep_customer_greeting(); ?></td>

         </tr>

         <tr>

           <td class="main"><br><?php echo TEXT_MAIN; ?></td>

         </tr>

         <tr>

           <td><br><?php include(DIR_WS_MODULES . FILENAME_DEFAULT_SPECIALS); ?></td>

         </tr>

         <tr>

           <td><br><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>

         </tr>

<?php

   include(DIR_WS_MODULES . FILENAME_UPCOMING_PRODUCTS);

?>

       </table></td>

     </tr>

   </table></td>

<?php

 }

?>

<!-- body_text_eof //-->

   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

   </table></td>

 </tr>

</table>

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- body_eof //-->



<!-- footer //-->

<!-- footer_eof //-->

<br>

<p>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

</body>

</html>

Share this post


Link to post
Share on other sites

Reemo,

 

did you change that in catalog/includes/english/default.php?

 

or did you change it in catalog/default.php?

 

I tried it and I'm either missing something or in the wrong spot.

 

I don't need the manufacturer's part to work but I would like the categories to display.

 

Thanks for any help you can give.


I'm not really a dog.

Share this post


Link to post
Share on other sites

you need to change /catalog/default.php

 

getting the catagories bit to display is the easy part just do what steve outlined in the third message in this thread...

im having trouble getting manufacturers bit right.. im going to look at steve's file soon and figure it out.

Share this post


Link to post
Share on other sites

Thanks Remo,

 

I thought it was catalog/default but Steve started this out by talking about the other default. I had also been told that changing the cat/default could be dangerous if ever upgrading but I guess this is a simple one.

 

John


I'm not really a dog.

Share this post


Link to post
Share on other sites

I followed the instructions several times and I now get this error:

 

Fatal error: Call to undefined function: tep_get_category_name() in /home/rapidmag/www/store/default.php on line 241

 

Any ideas?

 

Cheers,

 

David

Share this post


Link to post
Share on other sites

I know I use that function in some of my add-ons ... have you loaded any add-ons lately and forgotten an include or require on a function file? :shock:

Share this post


Link to post
Share on other sites

Thanks so much for getting back to me. I will try it again using an origional default file and see what happends. I have made some changes and that good stuff and that could be the problem.

 

I will let you know.

 

David :twisted:

Share this post


Link to post
Share on other sites

See if you have a file /catalog/includes/functions/categories_lookup.php

 

That is one location where I have that function in some of my Add-Ons.

Share this post


Link to post
Share on other sites

Fantastic, that worked out wonderful. I am not sure what was causing the error but now it is working like a peach.

 

Again, thaks for your help.

 

Cheers,

 

David :oha:

Share this post


Link to post
Share on other sites

I read all these replies and I am so confused! :)

 

I want to make it where if you click on the category or the manufacture it states their name at the top instead of Let's see what we have here.

Can someone take me thru this slow :)

 

Thanks

Share this post


Link to post
Share on other sites

This one did it for me.

 

In catalog/default.php, after:

 

 require('includes/application_top.php');

 

insert:

 

  

//category and manufacturer name hack starts

  function tep_get_category_name($category_id) { 

   global $languages_id; 



   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'"); 

   $category = tep_db_fetch_array($category_query); 



   return $category['categories_name']; 

 }  



 function tep_get_manufacturers_name($manufacturers_id) { 

   global $languages_id; 



   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $manufacturers_id . "'"); 

   $category = tep_db_fetch_array($manufacturers_query); 



   return $manufacturers['manufacturers_name']; 

 }  



 

//category and manufacturer name hack stops

 

Then replace first <?php echo HEADING_TITLE; ?>

 

with:

<?php echo $category['categories_name']; ?>

 

and second with:

 

<?php echo $manufacturers['manufacturers_name'];  ?>

 

Basically what Snowman wrote in the third message in this thread.


"Use no way as way, have no limitation as limitation." - Bruce Lee

Share this post


Link to post
Share on other sites

it's not working for me!!!

 

the file is not showing anything at all!!!

 

i even replace every <?php echo HEADING_TITLE; ?> with <?php echo $category['categories_name']; ?> and the with <?php echo $manufacturers['manufacturers_name']; ?> but it's not working..

 

some could help me?!

 

thanks in advance

emiliano


patagonia, argentina

Share this post


Link to post
Share on other sites

Really nice. Simple yet effective.

 

But you are selling your contribution short as in can be used on every page to replace alot more than the two headers, more like every header and by chancing:

 

<title><?php echo TITLE; ?></title>

 

to:

 

<title><?php echo $breadcrumb->last();  ?> :: <?php echo TITLE; ?></title>

 

It also automates the title tags for a nice boost in usability and search engine ratings (1000 times better than anything you can do with meta tags).

 

Works on every page as far as I can tell, but the product_info.php needs fix to the breadcrumb locig from:

 

http://forums.oscommerce.com/viewtopic.php?p=107851

 

to work. Same for the articles contribution if some one else is using it.

 

Simple, easy to add, useful. This contributions should be integrated to osc-core.


"Use no way as way, have no limitation as limitation." - Bruce Lee

Share this post


Link to post
Share on other sites

Just in case anyone wants to try this with ms1 release, here's a description of what I did.

 

Firstly, I added 2 functions to catalog/includes/functions/general.php (could also add to category_lookup.php as was suggested):

 

////

// KA - 04/18/03

// Return a category name

// TABLES: categories

 function tep_get_category_name($category_id) { 

   global $languages_id; 



   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'"); 

   $category = tep_db_fetch_array($category_query); 



   return $category['categories_name']; 

 } 



////

// KA - 04/18/03

// Return a manufacturers name

// TABLES: manufacturers	

 function tep_get_manufacturers_name($manufacturers_id) { 

   global $languages_id; 



   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $manufacturers_id . "'"); 

   $manufacturers = tep_db_fetch_array($manufacturers_query); 



   return $manufacturers['manufacturers_name']; 

 }

 

In catalog/default.php there are 3 cases where HEADING_TITLE is echo'd. I changed the first two as follows (not sure if the first 2nd is only manufacturers or also nested categories)...

 

<?php /* KA - 04/18/03 */ 

 if (isset($manufacturers_id)) {

   echo tep_get_manufacturers_name($manufacturers_id); 

 }

 else if (isset($current_category_id)) {

   echo tep_get_category_name($current_category_id); 

 }

 else echo HEADING_TITLE;

?>

 

It works for me.

 

Cheers

K


K

.....................................................................

When the going get's tough,

the tough get going.

Share this post


Link to post
Share on other sites

These are the 3 settings for defaults.php that work on categories, sub-categories, manufacturer, manufacture with selected category, category with selected manufacturer, etc. etc.

 

Replacement 1 ...

          <tr>

<?php /* WebMakers.com Added: Shoppe Enhancement Controller - include category name rather than HEADING_TITLE */ ?>

           <td class="pageHeading_section"><?php echo tep_get_categories_name($current_category_id); ?></td>

           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

         </tr>

 

Replacement 2 ...

          <tr>

<?php /* WebMakers.com Added: Shoppe Enhancement Controller - include category name rather than HEADING_TITLE */ ?>

           <td class="pageHeading_section"><?php echo tep_get_categories_name($current_category_id); ?></td>

           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

         </tr>

 

Replacement 3 ...

          <tr>

<?php /* WebMakers.com Added: Shoppe Enhancement Controller - include category name rather than HEADING_TITLE */ ?>

           <td class="pageHeading_section"><?php echo tep_get_manufacturers_name_id($HTTP_GET_VARS['manufacturers_id']) . tep_get_categories_name($current_category_id) . ' ' . tep_get_manufacturers_name_id($filter_id) . ' ' . (!$current_category_id ? tep_get_categories_name($filter_id) : ''); ?></td>

<?php

// optional Product List Filter

 

Functions used:

////

// WebMakers.com Added: Find a Categories Name

// TABLES: categories_description

 function tep_get_categories_name($who_am_i) {

   global $languages_id;

   $the_categories_name_query= tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $who_am_i . "' and language_id= '" . $languages_id . "'");



   $the_categories_name = tep_db_fetch_array($the_categories_name_query);

   return $the_categories_name['categories_name'];

 }

 

////

// Return a manufacturer name from manufacturer's id

// TABLES: manufacturer

function tep_get_manufacturers_name_id($manufactures_id) {



$the_manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $manufactures_id . "'");

$the_manufacturers = tep_db_fetch_array($the_manufacturers_query);



return $the_manufacturers['manufacturers_name'];

}

Share this post


Link to post
Share on other sites

Hi Linda (and all),

 

I've appreciated your posts as I've been lurking/researching/testing over the past month or so.

 

I'm working off of the 2.2ms1 release. So far, the only modification I have made and kept is the addition of Easy Populate and it doesn't impact catalog/default.php or catalog/includes/functions/general.php. However, I am yet unable to get a single hack recommended in this topic to work for me. Following your directions above in the previous posting:

These are the 3 settings for defaults.php (sic) that work on categories, sub-categories, manufacturer, manufacture with selected category, category with selected manufacturer, etc. etc.

This is exactly the functionality I am looking for. Could you confirm/correct some assumptions on my part?

 

Assumption 1

We are working with the unadultered files that came with 2.2ms1:

[*]default.php,v 1.81

[*]general.php,v 1.212

Assumption 2

When you mention the Replacements in your quote above I understand these to be in the (before being modified) catalog/default.php at the following lines:

[*]Replacement 1: Line 303

[*]Replacement 2: Line 65

[*]Replacement 3: Line 237

Assumption 3

and that in each case you are solely replacing (ex, Lines 65-68 ):

<tr>

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

         </tr>

with (your Replacement 2):

<tr> 

<?php /* WebMakers.com Added: Shoppe Enhancement Controller - include category name rather than HEADING_TITLE */ ?> 

? ? ? ? ? ? <td class="pageHeading_section"><?php echo tep_get_categories_name($current_category_id); ?></td> 

? ? ? ? ? ? <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 

? ? ? ? ? </tr>

 

Assumption 4

I don't have a class=pageHeading_section in my fresh copy of default.php and can't locate it so I am guessing that is a modification that you made of class=pageHeading?

 

Assumption 5

Are the functions that you are using belong in catalog/includes/functions/general.php ? Do they need to be located at any particular place in this file or can they be placed anywhere? For example, I added both of your functions at Line 75 after the function /// Return a product's name.

 

When I attempt these modifications I only get errors:

Parse error: parse error, unexpected T_FUNCTION in /Users/jeremy/Sites/clients_sites/docncys.com/catalog/includes/functions/general.php on line 78

 

Fatal error: Call to undefined function: tep_not_null() in /Users/jeremy/Sites/clients_sites/docncys.com/catalog/includes/application_top.php on line 433

Line 78 in general.php is from your "Find a Categories Name" function:

? function tep_get_categories_name($who_am_i) {

and Line 433 in application_top.php is the first line of:

  if (tep_not_null($cPath)) {

   $cPath_array = tep_parse_category_path($cPath);

   $cPath = implode('_', $cPath_array);

   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

 } else {

   $current_category_id = 0;

 }

Conclusion

I've been reading http://forums.oscommerce.com/, read http://guide.osdox.com/ and tried to find something useful at the under-progress http://wiki.oscommerce.com/ but am feeling like my attempts are nothing more than cut & paste voodoo :?

 

Any help is greatly appreciated. I'm working on a doc for myself to help remind me of each step I take as I make my installation of OSC work for my client(s) needs and look forward to publishing it for anyone to use.

 

Thanks in advance, --jeremy


Jeremy Crandell

Share this post


Link to post
Share on other sites

×