Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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


Snowman

Recommended Posts

Just as an add on in OSC2.2MS2 the 'Let's see what we have here' for manufactures can be easily be changed using the code below. This includes the category name change as well

 

in

catalog/includes/languages/english/index.php

 

change the code from

if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id'])) ) {
?define('HEADING_TITLE', 'Let\'s See What We Have Here');
?define('TABLE_HEADING_IMAGE', '');
?...
?...
} elseif ($category_depth == 'nested') {
?define('HEADING_TITLE', 'Categories');
}

 

to

 

if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id'])) ) {
?if (isset($HTTP_GET_VARS['manufacturers_id'])) {
? ?define('HEADING_TITLE', $manufacturers['manufacturers_name']. ' Products');
?}
?else{
? ?define('HEADING_TITLE', $categories['categories_name']);
?}
?define('TABLE_HEADING_IMAGE', '');
?...
?...
} elseif ($category_depth == 'nested') {
?define('HEADING_TITLE', $categories['categories_name']);
}

 

Rob

 

This works perfectly. Thank you so much Rob. Anybody looking for this solution. THIS ONE WORKS.

Link to comment
Share on other sites

  • Replies 101
  • Created
  • Last Reply

Instead of having the category name as the title for the category list I have, literally

HEADING_TITLE
. I replaced the code in includes/languages/english/index.php as directed above (Feb 23, 2004) and it had no effect.

 

I'm not using manufacturers so I can't check that, but all the other headers are working fine. The code in catalog/index.php looks ok:

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

 

Any ideas on what I have done and how to fix it??

Link to comment
Share on other sites

Thanks Barb. That was the same code I tried before, but you encouraged me to try again. I still had a tough time with it. Problem was I copied it off the post and pasted it into the code and picked up some invisible characters in the process. Deleted those and it worked fine.

Link to comment
Share on other sites

Help to revise above code!

 

what I'd like to do is create three different "if" statements:

 

Please help if you write code!

 

1. If Top>>Catalog>>Main cateogory is selcted, I'd like it to say "Now available in [Main Cateogry]" (Currently not working!) Need something like $heading_title_display = 'Now Available in' . " " . $main_cat_display; but will also allow for #2 below.

 

2. If Top>>Catalog>>Main Cateogory>>Sub category, I'd like it to say "Now available in [Main Category][sub Category]" (The code below from this thread does this already. Works great!)

 

3. And also if Top>>Catalog>>Manufacture name, then it will say "Now available in [Manufacturer] name. (Works with below code, but not formatted correctly)

 

Here is what I have so far:

 

// ****************************************************************************
// *****	Use the cPath variable to find category id
$main_cat_id = explode("_",$cPath);
$main_cat_id = $main_cat_id[0];
// *****	Query the db
$sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id ."'");
$row = tep_db_fetch_array($sql);
$main_cat_display = $row["categories_name"];
// *****	Avoid displaying "Books Books"
if ($categories['categories_name'] <> $main_cat_display){
$heading_title_display = 'Now Available in' . " " . $main_cat_display . " " . $categories['categories_name'];
}else {
$heading_title_display = 'Now Available in' . " " . $categories['categories_name'];
$heading_title_display = 'Now Available in' . " " . $manufacturers['manufacturers_name'];	
}
// ****************************************************************************

if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id'])) ) {
 define('HEADING_TITLE', $heading_title_display);
 define('TABLE_HEADING_IMAGE', '');
 //define('TABLE_HEADING_MODEL', 'Model');
 define('TABLE_HEADING_PRODUCTS', 'Product Name');
 define('TABLE_HEADING_MANUFACTURER', 'Manufacturer');
 define('TABLE_HEADING_QUANTITY', 'Quantity');
 define('TABLE_HEADING_PRICE', 'Price');
 define('TABLE_HEADING_WEIGHT', 'Weight');
 define('TABLE_HEADING_BUY_NOW', 'Buy Now');
 define('TEXT_NO_PRODUCTS', 'There are no products to list in this category.');
 define('TEXT_NO_PRODUCTS2', 'There is no product available from this manufacturer.');
 define('TEXT_NUMBER_OF_PRODUCTS', 'Number of Products: ');
 define('TEXT_SHOW', '<b>Show:</b>');
 define('TEXT_BUY', 'Buy 1 \'');
 define('TEXT_NOW', '\' now');
 define('TEXT_ALL_CATEGORIES', 'All Categories');
 define('TEXT_ALL_MANUFACTURERS', 'All Manufacturers');
} elseif ($category_depth == 'top') {
 define('HEADING_TITLE', 'Welcome');
} elseif ($category_depth == 'nested') {
 define('HEADING_TITLE', $heading_title_display);

 

Notice above that i added

$heading_title_display = 'Now Available in' . " " . $manufacturers['manufacturers_name'];

as part of the }else { statment, but I don't think I'm doing this right--It works and displays the manufacturer name, but it probably isn't formatted right.

Link to comment
Share on other sites

Here it is

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:38:00 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

define('TEXT_MAIN', 'This shop is running on osCommerce version <font color="#f0000"><b>' . PROJECT_VERSION . '</b></font>.');
define('TABLE_HEADING_NEW_PRODUCTS', 'New Products For %s');
define('TABLE_HEADING_UPCOMING_PRODUCTS', 'Upcoming Products');
define('TABLE_HEADING_DATE_EXPECTED', 'Date Expected');

if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id'])) ) {
 define('HEADING_TITLE', $categories['categories_name']);
 define('TABLE_HEADING_IMAGE', '');
 define('TABLE_HEADING_MODEL', 'Model');
 define('TABLE_HEADING_PRODUCTS', 'Product Name');
 define('TABLE_HEADING_MANUFACTURER', 'Manufacturer');
 define('TABLE_HEADING_QUANTITY', 'Quantity');
 define('TABLE_HEADING_PRICE', 'Price');
 define('TABLE_HEADING_WEIGHT', 'Weight');
 define('TABLE_HEADING_BUY_NOW', 'Buy Now');
 define('TEXT_NO_PRODUCTS', 'There are no products to list in this category.');
 define('TEXT_NO_PRODUCTS2', 'There is no product available from this manufacturer.');
 define('TEXT_NUMBER_OF_PRODUCTS', 'Number of Products: ');
 define('TEXT_SHOW', '<b>Show:</b>');
 define('TEXT_BUY', 'Buy 1 \'');
 define('TEXT_NOW', '\' now');
 define('TEXT_ALL_CATEGORIES', 'All Categories');
 define('TEXT_ALL_MANUFACTURERS', 'All Manufacturers');
} elseif ($category_depth == 'top') {
 define('HEADING_TITLE', 'What\'s New Here?');
} elseif ($category_depth == 'nested') {
define('HEADING_TITLE', $categories['categories_name']);
}
?>

Link to comment
Share on other sites

I removed the "Lets see what we got here.." with Tommy916's contribution (v.26/02/2004).

In this thread I requested for help but no reaction yet.

 

Maybe someone here can help me.

How to tweak it to show not just the last but the last 2 subcategories?!?

My categories contain subcategories with models.

A model is split in years. I would like to see the Model and Year as Page Heading...

 

TIA

Link to comment
Share on other sites

This should display names for all subcategories.

 

1 - ADD THESE LINES AFTER

define('TABLE_HEADING_DATE_EXPECTED', 'Date Expected');

// ****************************************************************************
// ***** Use the cPath variable to find category ids
$main_cat_id = explode("_",$cPath);
// ***** Change the next line to whatever you like or delete it
$heading_title_display = "Now Available In<br>";
for ($test=0; $test<count($main_cat_id); $test++){
 // ***** Query the db to convert id numbers to names
 $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] ."'");
 $row = tep_db_fetch_array($sql);
 // ***** Add the name to the display
 $heading_title_display .= $row["categories_name"];
 // ***** If not the last item in array add a dash (or whatever)
 if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
}
// ****************************************************************************

2 - REPLACE THE 'products' HEADING TITLE LINE WITH THIS:

  define('HEADING_TITLE', $heading_title_display);

 

3 - (Optional) REPLACE THE 'TOP' HEADING TITLE LINE WITH THIS:

  define('HEADING_TITLE', 'Welcome');

 

4 - REPLACE THE 'nested' HEADING TITLE LINE WITH THIS:

  define('HEADING_TITLE', $heading_title_display);

Link to comment
Share on other sites

Stephen,

Thanks for your reply!

 

Can't we just tweak the code I use a little?:

/*
FOR SUBCATEGORIES, just replace in catalog/index.php the second
<?php echo HEADING_TITLE; ?>
TO
*/

<?php 
 $category_query1 = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
  $category1 = tep_db_fetch_array($category_query1);
  
if ($category1['categories_name'] != "") {echo $category1['categories_name'];} else { echo HEADING_TITLE;} 
?>

I like this code because its a little easyer in the future. I'm planning to ad several languages.

Link to comment
Share on other sites

Looks like the only real diference is in the sql - i am not good at sql, it makes my brain hurt but...

// ****************************************************************************
// ***** Use the cPath variable to find category ids
$main_cat_id = explode("_",$cPath);
$heading_title_display = "";
// ***** Change the next line(s) to whatever you like or delete them
// ***** Check your db to determine id number for each language
switch ((int)$languages_id) {
case "1": // ***** Language 1
  $heading_title_display = "Now Available In<br>";
  break;
case "2": // ***** Language 2
  $heading_title_display = "Now Available In<br>";
  break;
case "3": // ***** Language 3
  $heading_title_display = "Now Available In<br>";
  break;
}

for ($test=0; $test<count($main_cat_id); $test++){
// ***** Query the db to convert id numbers to names
$sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] ."'");
$row = tep_db_fetch_array($sql);
// ***** Add the name to the display
$heading_title_display .= $row["categories_name"];
// ***** If not the last item in array add a dash (or whatever)
if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
}
// ****************************************************************************
// ***** if $category1['categories_name'] is used elsewhere
$category1['categories_name'] = $heading_title_display;
if ($category1['categories_name'] != "") {echo $category1['categories_name'];} else { echo HEADING_TITLE;}

Link to comment
Share on other sites

Arrrrgh - I can't even cut/paste sql correctly. replace the above post with this.

 

// ****************************************************************************

// ***** Use the cPath variable to find category ids

$main_cat_id = explode("_",$cPath);

$heading_title_display = "";

// ***** Change the next line(s) to whatever you like or delete them

// ***** Check your db to determine id number for each language

switch ((int)$languages_id) {

case "1": // ***** Language 1

  $heading_title_display = "Now Available In<br>";

  break;

case "2": // ***** Language 2

  $heading_title_display = "Now Available In<br>";

  break;

case "3": // ***** Language 3

  $heading_title_display = "Now Available In<br>";

  break;

}

 

for ($test=0; $test<count($main_cat_id); $test++){

// ***** Query the db to convert id numbers to names

$sql = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$main_cat_id[$test] . "' and cd.categories_id = '" . (int)$main_cat_id[$test] . "' and cd.language_id = '" . (int)$languages_id . "'");

$row = tep_db_fetch_array($sql);

// ***** Add the name to the display

$heading_title_display .= $row["categories_name"];

// ***** If not the last item in array add a dash (or whatever)

if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}

}

// ****************************************************************************

// ***** if $category1['categories_name'] is used elsewhere

$category1['categories_name'] = $heading_title_display;

if ($category1['categories_name'] != "") {echo $category1['categories_name'];} else { echo HEADING_TITLE;}

Link to comment
Share on other sites

Errors, maybe because I don't paste your source correct.

 

I've checked my catalog/index.php and this is the source:

            <td class="pageHeading"><?php if (isset($HTTP_GET_VARS['manufacturers_id'])) {  
       $category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
       $category = tep_db_fetch_array($category_query);
       if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}
     } else { 
       $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
       $category = tep_db_fetch_array($category_query);
       if ($category['categories_name'] != "") {echo $category['categories_name'];} else { echo HEADING_TITLE;}
     }
?></td>

How to paste your source between the class="pageHeading"> and </td>?

I'm gratefull if you would help this php-dummy :huh:

Link to comment
Share on other sites

OK - I set up a fresh install to test this and it is working for me at

hullabaloo.net/testshop. So if I can copy/paste correctly...

 

Using Tommy916's contribution as a model I did the following:

 

1. Find and replace the first <?php echo HEADING_TITLE; ?> with

	<?php 
// ***** Check your db to determine id number for each language
switch ((int)$languages_id) {
 case "1": // ***** Language 1
	 $now = "Now Available In(English)<br>";
	 break;
 case "2": // ***** Language 2
	 $now = "Now Available In(German)<br>";
	 break;
 case "3": // ***** Language 3
	 $now = "Now Available In(Spanish)<br>";
	 break;
}
echo $now . " " . $category['categories_name'] 
?>

2. For subcategories replace the second <?php echo HEADING_TITLE; ?> with

 	 <?php 
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {  
   $category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   $category = tep_db_fetch_array($category_query);
   if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}
	 } else {
   // ***** Use the cPath variable to find category ids
   $main_cat_id = explode("_",$cPath);
   $heading_title_display = "";
   // ***** Change the next line(s) to whatever you like or delete them
   // ***** Check your db to determine id number for each language
   switch ((int)$languages_id) {
  	 case "1": // ***** Language 1
     $heading_title_display = "Now Available In(E)<br>";
     break;
  	 case "2": // ***** Language 2
     $heading_title_display = "Now Available In(G)<br>";
     break;
  	 case "3": // ***** Language 3
     $heading_title_display = "Now Available In(S)<br>";
     break;
   }
   for ($test=0; $test<count($main_cat_id); $test++){
  	 // ***** Query the db to convert id numbers to names
  	 $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] . "'and language_id = '" . (int)$languages_id . "'");
  	 $row = tep_db_fetch_array($sql);
  	 // ***** Add the name to the display
  	 $heading_title_display .= $row["categories_name"];
  	 // ***** If not the last item in array add a dash (or whatever)
  	 if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
   }
   if ($heading_title_display != "") {echo $heading_title_display;} else { echo HEADING_TITLE;}
	 }
	 ?>

Link to comment
Share on other sites

Stephen, many thanks! :thumbsup:

It would be perfect for my needs if it didn't show the headcategorie and "Now Available In.

Instead "dvd movies - action - bruce willis" I would like to show "action - bruce willis".

 

Greetingzzz

Link to comment
Share on other sites

Stephen, many thanks! :thumbsup:

It would be perfect for my needs if it didn't show the headcategorie and "Now Available In.

Instead "dvd movies - action - bruce willis" I would like to show "action - bruce willis".

 

Greetingzzz

 

Glad to help. I am not sure what you want. I have changed testshop to show what I think you want.

Click DVD Movies Shows "DVD Movies"

Click Action Shows "DVD Movies - Action"

Click Bruce Shows "Action - Bruce Willis"

 

Is that it?

 

First part is easy just get rid of the Now Available In stuff...

 

1. Find and replace the first <?php echo HEADING_TITLE; ?> with

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

2. For subcategories replace the second <?php echo HEADING_TITLE; ?> with

<?php 
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {  
   $category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   $category = tep_db_fetch_array($category_query);
   if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}
	 } else {
   // ***** Use the cPath variable to find category ids
   $main_cat_id = explode("_",$cPath);
   $heading_title_display = "";
   
   $where_to_start = count($main_cat_id);
	 if ($where_to_start >2) {$where_to_start = 1;} else {$where_to_start = 0;}
   for ($test=$where_to_start; $test<count($main_cat_id); $test++){
  	 // ***** Query the db to convert id numbers to names
  	 $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] . "'and language_id = '" . (int)$languages_id . "'");
  	 $row = tep_db_fetch_array($sql);
  	 // ***** Add the name to the display
  	 $heading_title_display .= $row["categories_name"];
  	 // ***** If not the last item in array add a dash (or whatever)
  	 if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
   }
   if ($heading_title_display != "") {echo $heading_title_display;} else { echo HEADING_TITLE;}
	 }
	 ?>

Link to comment
Share on other sites

GREAT!, almost what I want :)

 

Instead of:

Click DVD Movies Shows "DVD Movies"

Click Action Shows "DVD Movies - Action"

Click Bruce Shows "Action - Bruce Willis"

 

I would like to show:

Click DVD Movies Shows "DVD Movies"

Click Action Shows "Action"

Click Bruce Shows "Action - Bruce Willis"

 

In my case it's:

Click Exterior Shows "Exterior"

Click Model Shows "Model"

Click Year Shows "Model - Year"

Link to comment
Share on other sites

On the original issue,

The first one I used:

<?php echo HEADING_TITLE . $categories['categories_name']; ?>

 

The second one I used:

echo HEADING_TITLE . $categories['categories_name'] . $manufacturers['manufacturers_name'];

 

first one takes care of those sub-catagory pages.

 

second one handles both catagory and manufacturer pages.

the two strings are never set at the same time, so your message will display correct.

 

HEADING_TITLE can be removed if you preferr or left in there and edited in the language file (manufacturer and catagory versions will show correctly)

 

good luck with it folks.

seems to work fine for me

 

I didn't need the lengthy tracking of catagory depths, sorry.. haven't been following

that portion.

Link to comment
Share on other sites

GREAT!, almost what I want  :)

 

Instead of:

Click DVD Movies Shows "DVD Movies"

Click Action Shows "DVD Movies - Action"

Click Bruce Shows "Action - Bruce Willis"

 

I would like to show:

Click DVD Movies Shows "DVD Movies"

Click Action Shows "Action"

Click Bruce Shows "Action - Bruce Willis"

 

In my case it's:

Click Exterior Shows "Exterior"

Click Model Shows "Model"

Click Year Shows "Model - Year"

 

Try this...

 	 <?php 
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {  
   $category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   $category = tep_db_fetch_array($category_query);
   if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}
	 } else {
   // ***** Use the cPath variable to find category ids
   $main_cat_id = explode("_",$cPath);
   $heading_title_display = "";
   $where_to_start = count($main_cat_id);
   if ($where_to_start = 3) {
  	 for ($test=1; $test<count($main_cat_id); $test++){
     // ***** Query the db to convert id numbers to names
     $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] . "'and language_id = '" . (int)$languages_id . "'");
     $row = tep_db_fetch_array($sql);
     // ***** Add the name to the display
     $heading_title_display .= $row["categories_name"];
     // ***** If not the last item in array add a dash (or whatever)
     if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
  	 }
   }
   if ($heading_title_display != "") {echo $heading_title_display;} else { echo HEADING_TITLE;}
	 }
	 ?>

Link to comment
Share on other sites

Thank you so much for helping me Stephen!

Now if there's no subcategorie it show's the "What we have here" again :o

I can't get my test site to show "what we have here" - did you replace the first <?php echo HEADING_TITLE; ?> with

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

Link to comment
Share on other sites

I can't get my test site to show "what we have here" - did you replace the first <?php echo HEADING_TITLE; ?> with

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

I understand now. This Should Fix Everything. (Famous last words...)

 	 <?php 
	 if (isset($HTTP_GET_VARS['manufacturers_id'])) {  
   $category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   $category = tep_db_fetch_array($category_query);
   if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}
	 } else {
   $main_cat_id = explode("_",$cPath);
   $heading_title_display = "";
   $where_to_start = count($main_cat_id);
   if ($where_to_start == 1) {
  	 $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[0] . "'and language_id = '" . (int)$languages_id . "'");
  	 $row = tep_db_fetch_array($sql);
  	 $heading_title_display .= $row["categories_name"];
  	 }
   if ($where_to_start > 1) {
  	 for ($test=1; $test<count($main_cat_id); $test++){
     $sql = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id='" . $main_cat_id[$test] . "'and language_id = '" . (int)$languages_id . "'");
     $row = tep_db_fetch_array($sql);
     $heading_title_display .= $row["categories_name"];
     if($test < (count($main_cat_id)-1)){$heading_title_display .= " - ";}
  	 }
   }
   if ($heading_title_display != "") {echo $heading_title_display;} else { echo HEADING_TITLE;}
	 }
	 ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...