Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Custom text when no products in a category


thewitt

Recommended Posts

Posted

Is there a simple way to customize the text that's shown in each category if there are no products currently defined or active for a category?

 

I have a couple of categories that are often without any currently available products (one-offs, etc) and would like to have a short paragraph of text when there are no products available. It needs to be custom to each category or sub-category however.

 

Any ideas?

 

Thanks,

 

-t

Posted

if it's only a couple of categories and not changing rapidly you could check for an include file with the category name.

If it's there it includes it, of not it shows the text.

 

 

// SEMI CODE

// default.php where is shows 'no products found'



$my_file = '/path/to/' . $categories_id . '.html';



if (file_exists($my_file) {

   include($my_file);

} else {

   echo NO_PRODUCTS_FOUND;

}

 

hth

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Posted
..include file with the category name..

 

should be category ID obviously.

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Posted

Thanks Mattice, great idea. I will play with keying off the category id and adding this as an admin function so that people don't need to know what the category id is in order to add custom text here.

 

-t

Posted

Just to close the loop here in case anyone else wants to do this in the future, I ended up added a text field to the categories table in the database and made the following changes to the v1.39 version of the file catalog/includes/modules/product_listing.php

 

Just below the section:

    

<?php echo ($HTTP_GET_VARS['manufacturers_id'] ? TEXT_NO_PRODUCTS2 : TEXT_NO_PRODUCTS); ?> </td>

 </tr>

<?php

 

I added the following:

 

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

   $noproduct_text = tep_db_fetch_array($noproduct_text);

   $noproduct_text = $noproduct_text['noproduct_text'];

 

   if ($noproduct_text != '') {

?>

   <tr>

     <td><?php echo tep_draw_separator(); ?></td>

   </tr>

   <tr class="productListing-data">

     <td><?php echo $noproduct_text; ?></td>

   </tr>

<?php

 

And I added the field "noproduct_text" to the categories table.

 

Works like a charm.

 

I may or may not get around to making an admin change for this. We'll see. Right now I just edit the table in phpMyAdmin and I'm all set. The text for me is static for any given category.

 

-t

Archived

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

×
×
  • Create New...