Project / Support Center
Welcome, Guest. Please login or register. August 13, 2022, 12:58: PM
Home Help Search Login Register
D-Web Web Site Creator D - Web Web Site Creator On-line HTML Editor No Programming knowledge required. Web Global Net PayPal-Cart Shopping Cart System PayPal - Kart Shopping Cart System for E-Commerce over the internet, that's easy to use. Web Global Net Newsletter Manager Newsletter Manager On-line Newsletter Creator with Email Subscriber Management.
Ring Central Discount
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Open Source Topics  |  OS Commerce  |  Topic: categories show if 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Send this topic Print
Author Topic: categories show if  (Read 9442 times)
admin
Guest
« on: February 14, 2008, 09:05: PM »

I was looking for a way to hide empty Categories and Sub-Categories in the $catmenu to avoid having the user click on a Category only for it to say "No products found". I ran across this contrib: http://addons.oscommerce.com/info/5475 and just "borrowed" the if-statement and it seems to work just fine. So here it is:

In the sts_user_code.php file, in the Category Menu Code:

Find:
CODE
while ($categories = tep_db_fetch_array($categories_query)) {

...and ADD this below it:
CODE
// Begin Hide Empty Categories and Sub Categories
if (tep_count_products_in_category($categories['categories_id']) > 0) {
// End Hide Empty Categories and Sub Categories

Then you need to close out the if-statement so find:
CODE
$category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);

And just ADD this below it:
CODE
// Begin Hide Empty Categories and Sub Categories
}
// End Hide Empty Categories and Sub Categories


Again, I totally snatched the code from the above mentioned, very fine contribution. This is just how you apply it to the sts_user_code.php file.
Report to moderator   Logged
Pages: [1] Go Up Send this topic Print 
Web Global Net Web Application & Web Development Project Center  |  Technical Issues  |  Open Source Topics  |  OS Commerce  |  Topic: categories show if « previous next »
Jump to:  


Login with username, password and session length
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!