Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Bootstrap Home Page Carousel Banner Slider Module Plugin Complete - Testing Welcome


Recommended Posts

There are a number of Addons that allow you to hide one or more categories. I don't remember if there is one for the Bootstrap versions, but one that works for standard 2.3.4 should also work for Bootstrap.

 

You could automate this by using the products_to_categories table in the database. If there is no entry for a given categories_id, then there are no products in that category. You could also join the categories table in the SQL you are using to the products_to_categories table, as the join will automatically exclude any cases where a categories_id is not present in both tables.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 61
  • Created
  • Last Reply

There are a number of Addons that allow you to hide one or more categories. I don't remember if there is one for the Bootstrap versions, but one that works for standard 2.3.4 should also work for Bootstrap.

 

You could automate this by using the products_to_categories table in the database. If there is no entry for a given categories_id, then there are no products in that category. You could also join the categories table in the SQL you are using to the products_to_categories table, as the join will automatically exclude any cases where a categories_id is not present in both tables.

 

Regards

Jim

 

Thanks, Jim.

 

I took your suggestion and wrote a bit of code. This is the entire function from the includes/functions/general.php file. I added comments to show what I changed...

function tep_build_category_info_array() {
    function bci_get_paths($categories_array = '', $parent_id = 0, $level = 0, $path='') {
      global $languages_id;
      if (!is_array($categories_array)) $categories_array = array();
      
      //I changed this...
      //$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
       
      //To this...
      $categories_query = tep_db_query("select c.categories_id, cd.categories_name, p2c.categories_id, p2c.products_id, p.products_id, p.products_status from " . TABLE_CATEGORIES . " c left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on c.categories_id = p2c.categories_id left join " . TABLE_PRODUCTS . " p on p2c.products_id = p.products_id, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p2c.products_id <> '' and p.products_status <> '0' and parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
      
      
      
      while ($categories = tep_db_fetch_array($categories_query)) {
        if (SHOW_COUNTS == 'true') {
          $count_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = " . (int)$categories['categories_id']);
          $products = tep_db_fetch_array($count_query);
          $count = $products['total'];
        } else {
          $count = 0;
        }
    	  $categories_array[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                  'path' => $path . $categories['categories_id'],
                                  'id' => $categories['categories_id'],
                                  'indent' => str_repeat('  ', $level),
                                  'level' => $level,
                                  'has_subcat' => false,
                                  'prod_count' => $count,
                                  'parent' => $parent_id,
                                  'direct_children' => array(),
                                  'all_children' => array(),
                                  'with_children' => array($categories['categories_id']));
        $categories_array[$parent_id]['has_subcat'] = true;
        $categories_array[$parent_id]['direct_children'][] = $categories['categories_id'];
        if ($categories['categories_id'] != $parent_id) {
          $categories_array = bci_get_paths($categories_array, $categories['categories_id'], $level + 1, $path . $categories['categories_id'] . '_');
        }
      }
      return $categories_array;
    } // end bci_get_paths

    $cat_array = bci_get_paths();
    unset($cat_array[0]);
    foreach ($cat_array as $cat) {
      $parent = $cat['parent'];
      while ($parent > 0 ) {
        // add category product count to parent category product counts
        $cat_array[$parent]['prod_count'] += $cat['prod_count'];
        // build all_children and with_children arrays
        $cat_array[$parent]['all_children'][] = $cat['id'];
        $cat_array[$parent]['with_children'][] = $cat['id'];
        $parent = $cat_array[$parent]['parent'];
      }
    }
    return $cat_array;
  } // end tep_build_category_info_array

This seems to work great, but only for the main categories. I don't know how to make it look in the subcategories to find products. For example, I have a category called wheels. Inside that I have a subcategory called hubcaps. The wheels category will only show up if I have a product directly inside of it. It doesn't matter that I have a product in the hubcaps category; it doesn't look for that and the whole tree gets hidden if it doesn't find a product in the wheels category.

 

Can you please help point me in the right direction?

 

Thanks,

Randy 

Link to comment
Share on other sites

You have a function inside a function:

function tep_build_category_info_array() {
    function bci_get_paths($categories_array = '', $parent_id = 0, $level = 0, $path='') {

That can't possibly work. Getting rid of that, your SQL does exactly what you said you wanted: if removes all categories that have no products. Apparently what you really wanted is to remove all categories that have no products or subcategories. That's quite a bit harder to do.

 

I suggest that you go find an addon that is designed to hide categories. I remember there being several of those.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

You have a function inside a function:

function tep_build_category_info_array() {
    function bci_get_paths($categories_array = '', $parent_id = 0, $level = 0, $path='') {

That can't possibly work. Getting rid of that, your SQL does exactly what you said you wanted: if removes all categories that have no products. Apparently what you really wanted is to remove all categories that have no products or subcategories. That's quite a bit harder to do.

 

I suggest that you go find an addon that is designed to hide categories. I remember there being several of those.

 

Regards

Jim

 

Thanks. That function inside of a function is part of the Enhanced Categories Box addon. I didn't write it; I only added it to my store. And it works fine. It just doesn't offer the "hide the category if it has no products or subcategories with products in it". I'm just trying to make this feature a little bit more useful for what I would like my store to do. That's all. 

 

And, yes, there are several addons that hide categories with no products. But I haven't found any that work with Bootstrap 2.3.4. I'm sorry to have bothered you. My apologies.

 

Randy

Link to comment
Share on other sites

You're not bothering me. I'm trying to help, but the result that you want is not simple and would take some thought.

 

Any Addon for osC 2.3.4 can be made to work with the Bootstrap versions. Addons that just modify SQL, such as to block certain categories, are the easiest to adapt. Take a look and see what you come up with.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 2 months later...

There is no Add-on to Hide Categories for Bootstrap? a relay Important requirement, As an Old OsC user and Store owner I thing oscommerce goes away from the Good Old free times ...V2.2 and V2.3 after BS everything good and important have to be paid!

Link to comment
Share on other sites

There is no Add-on to Hide Categories for Bootstrap? a relay Important requirement, As an Old OsC user and Store owner I thing oscommerce goes away from the Good Old free times ...V2.2 and V2.3 after BS everything good and important have to be paid!

 

To move osCommerce forward, we need to attract talented developers. How to do that? Make it rewarding for them to work. Their love of osCommerce can only go so far, so if developers can make money from their efforts they are far more likely to stick around. Your support, by buying addons or getting developers to do work on your site, helps immensely no matter how small.

 

If osCommerce is good to you, put something back. If funds are tight, ask how you can help. Every little bit helps.

osCommerce user since 2003! :thumbsup:

Link to comment
Share on other sites

  • 10 months later...

Hi,

Thank you for this add-on... Great.

I had the famous deprecated constructor with PHP7.

===========================
I change this line :

    function cm_carousel() {
 

For this line :

    function __construct() {

===========================

No more error... 

Is anybody found how to change the height of the carousel ?

I tried some setting in user.css and the file cm.carousel.php but no Cigar !!!

Cheers.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

  • 2 months later...


 

tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Banner Rotator Max Banners', 'MODULE_FRONT_PAGE_BANNER_ROTATOR_MAX_DISPLAY', '5', 'Maximum number of banners that the Banner Rotator will show', '6', '0', now())");
    }

I am trying to increase the number of banners that show,  it looks like the max was set to four,  I have 5. tried increasing here -no luck

'MODULE_FRONT_PAGE_BANNER_ROTATOR_MAX_DISPLAY', '5',

thanks 

zpupster

Link to comment
Share on other sites

  • 4 weeks later...

Hi all,

I created and installed all three files told here but it is not working on my edge version.

Is that ALL I need, just these there files, I can see the module in the admin area and I can edit the module in admin but no banner shows up in the front page! Do I need to install any other files like the full module from the add on area or just the three files are enough!

Many thanks in advance

Mitchell

 

Link to comment
Share on other sites

  • 1 year later...

Archived

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

×
×
  • Create New...