Page 2 of 4

Re: Subcatagory

Posted: Wed Jan 20, 2010 3:42 pm
by jkungfu
thanks! it works!

Re: Subcatagory

Posted: Thu Jan 21, 2010 3:54 am
by lith07
Hey does anyone know how to do this in v0.x? Thanks!

Re: Subcatagory

Posted: Wed Jul 21, 2010 9:56 pm
by WSurfer
Qphoria wrote:Try this:

Change:

Code: Select all

$children = $this->getCategories($result['category_id'], $new_path);
To:

Code: Select all

if (substr_count($new_path, '_') < 1) {
    $children = $this->getCategories($result['category_id'], $new_path);
}
Hi!

I applied this code to my web store and it's working great; I set < 2 so main category and subcategory are displayed.
But here is the problem... I have 2nd and 3rd level sub categories added to my categories as well and in case someone click in 1st level of subcategory second one (second level of subcategory) doesn't appear.

What I would like is to have displayed main category and first subcategory, but when someone click on this subcategory, subcategory of this subcategory should be displayed as well (in case there is sub-subcategory).

Can someone please help me on this?

Re: Subcatagory

Posted: Mon Aug 30, 2010 7:10 am
by Boxerworks
We too are having this same issue. Boxerworks is using the latest incarnation of OpenCart - 1.4.9. I would have thought something like this would have been solved WAY before now as it appears to be an ongoing issue starting many versions back.

Is there a mod someone can recommend that would provide a bandaid for this issue? Please advise ASAP. Thank you.

Re: Subcatagory

Posted: Thu Oct 14, 2010 8:01 pm
by hagelslag
Qphoria wrote:all categories work with SEO for me.. even 4 levels deep
Hi Q,

How do you do that?
As soon as i use a SEO keyword for a product, the breadcrumb and Category module links are lost as soon as you click that product.

I have set up an example with 2 products here:
http://bit.ly/cpuD61


One product with an SEO keyword, and one without. As you can see, if you click the left one, the subcat. closes and the subcat in the breadcrumb padth too.
Any idea why?

Thanks in advance!

Re: Subcatagory

Posted: Thu Oct 14, 2010 9:05 pm
by Qphoria
I dont' see any SEO on your site.
My demo shows
Desktop as the parent category with seo "desktop"
PC as the subcategory with seo "pc"
HP LP3065 as the product with seo "HP-LP3065"

http://unbannable.com/v149/desktops/pc

Re: Subcatagory

Posted: Thu Oct 14, 2010 9:24 pm
by hagelslag
Hi,
First i only had SEO on the product itself. Now with SEO on the cat and subcat it works! Thanks.

Re: Subcatagory

Posted: Thu Oct 14, 2010 9:25 pm
by hagelslag
Q, it even works perfect with your multiple cat block module!!
Great.

Re: Subcatagory

Posted: Fri Oct 15, 2010 11:30 pm
by jty
hagelslag wrote:Q, it even works perfect with your multiple cat block module!!
Great.
Thanks Hagelslag
With the help of Mr Q's Category Box Clone found here http://theqdomain.com/ocstore/opencart_ ... _box_clone
I have been able to solve my menu problem that has been frustrating me for a couple of months.

Re: Subcatagory

Posted: Sat Oct 23, 2010 2:19 am
by grongor
hagelslag wrote: Hi Q,
How do you do that?
As soon as i use a SEO keyword for a product, the breadcrumb and Category module links are lost as soon as you click that product.
I have set up an example with 2 products here:
http://bit.ly/cpuD61
One product with an SEO keyword, and one without. As you can see, if you click the left one, the subcat. closes and the subcat in the breadcrumb padth too.
Any idea why?
Thanks in advance!
Hello, I had same problem too now. I was looking into it for some minutes and I think I figured it out. I am using OC just one day lol, but I hope it will work, try it:
Instead of lines ~55-57

Code: Select all

if ($category_id == $result['category_id']) {
	$children = $this->getCategories($result['category_id'], $new_path);
}
Use this

Code: Select all

if ($category_id == $result['category_id']) {
	$children = $this->getCategories($result['category_id'], $new_path);
}elseif(substr_count($new_path, '_') < 1){
        array_unshift( $this->path, $category_id );
        $children = $this->getCategories($result['category_id'], $new_path);
 }
If you find an bug, please tell me :)

Re: Subcatagory

Posted: Tue Jul 12, 2011 4:00 pm
by pixelpuncher
thank you!!!

Re: Subcatagory

Posted: Sun Jul 17, 2011 6:05 pm
by DrunkMunki
is there a version of this code for version 1.5?
i notice the html code is the same, the php code is different, could this be done through css?

attached is the /catalog/controller/module/category.php file.

Code: Select all

<?php  
class ControllerModuleCategory extends Controller {
	protected function index() {
		$this->language->load('module/category');
		
    	$this->data['heading_title'] = $this->language->get('heading_title');
		
		if (isset($this->request->get['path'])) {
			$parts = explode('_', (string)$this->request->get['path']);
		} else {
			$parts = array();
		}
		
		if (isset($parts[0])) {
			$this->data['category_id'] = $parts[0];
		} else {
			$this->data['category_id'] = 0;
		}
		
		if (isset($parts[1])) {
			$this->data['child_id'] = $parts[1];
		} else {
			$this->data['child_id'] = 0;
		}
							
		$this->load->model('catalog/category');
		$this->load->model('catalog/product');
		
		$this->data['categories'] = array();
					
		$categories = $this->model_catalog_category->getCategories(0);
		
		foreach ($categories as $category) {
			$children_data = array();
			
			$children = $this->model_catalog_category->getCategories($category['category_id']);
			
			foreach ($children as $child) {
				$data = array(
					'filter_category_id'  => $child['category_id'],
					'filter_sub_category' => true
				);		
					
				$product_total = $this->model_catalog_product->getTotalProducts($data);
							
				$children_data[] = array(
					'category_id' => $child['category_id'],
					'name'        => $child['name'] . ' (' . $product_total . ')',
					'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
				);					
			}
			
			$data = array(
				'filter_category_id'  => $category['category_id'],
				'filter_sub_category' => true	
			);		
				
			$product_total = $this->model_catalog_product->getTotalProducts($data);
						
			$this->data['categories'][] = array(
				'category_id' => $category['category_id'],
				'name'        => $category['name'] . ' (' . $product_total . ')',
				'children'    => $children_data,
				'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
			);
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/category.tpl';
		} else {
			$this->template = 'default/template/module/category.tpl';
		}
		
		$this->render();
  	}
}
?>

Re: Subcatagory

Posted: Thu Jul 21, 2011 4:17 pm
by DrunkMunki
ok i think i have solved my issue, all i did was change/remove

Code: Select all

.box-category > ul > li ul {
	display: none;
}
to

Code: Select all

.box-category > ul > li ul {
	/*display: none;*/
}
e.g remove the display: none

Re: Subcatagory

Posted: Fri Aug 12, 2011 2:05 pm
by OnNets
Hi,

Any update for v1.5.1.1 ?

I want to make the sub-category always showing.

Thanks

Re: Subcatagory

Posted: Sun Aug 21, 2011 7:52 pm
by OnNets
Anyone....help??

Re: Subcatagory

Posted: Sun Sep 25, 2011 7:20 pm
by kevinbud
Did anyone figure this out (subcategories always showing) in v1.5.1?

Thanks

Re: Subcatagory

Posted: Sun Sep 25, 2011 9:33 pm
by Qphoria
If you follow DrunkMunki's post that will show all subs at all times. However, there is a 2 level max that can be displayed at this time so if you have:
Parent
----SubA
----SubB
--------SubSubB


You won't see SubSubB as it is the 3rd level

This was done to cut down on the page loading times because the recursive category query is very taxing.

But perhaps that should be left to the discretion of the admin to choose how many levels are shown at the per-module basis.

Re: Subcatagory

Posted: Wed Nov 16, 2011 4:01 am
by Xciso
Anyone know how to fix this for 1.5.1.3?
Or how i can make a tree. U know with the + if it excist subs and - if it not excist..

Please help!

Re: Subcatagory

Posted: Sat Nov 19, 2011 1:19 am
by quocbinhvip
grongor wrote: Hello, I had same problem too now. I was looking into it for some minutes and I think I figured it out. I am using OC just one day lol, but I hope it will work, try it:
Instead of lines ~55-57

Code: Select all

if ($category_id == $result['category_id']) {
	$children = $this->getCategories($result['category_id'], $new_path);
}
Use this

Code: Select all

if ($category_id == $result['category_id']) {
	$children = $this->getCategories($result['category_id'], $new_path);
}elseif(substr_count($new_path, '_') < 1){
        array_unshift( $this->path, $category_id );
        $children = $this->getCategories($result['category_id'], $new_path);
 }
If you find an bug, please tell me :)
It works very well. but I need a little more such as:
----SubA
--------Sub Su1
--------SubSub2
----SubB
--------Sub Su1
--------SubSub2
--------Sub Su3
--------SubSub4
We hope to receive help from you. thanks much

Re: Subcatagory

Posted: Thu Dec 01, 2011 4:03 pm
by xseon
The solution here is the same as the one found at One more level of subcategory. The only difference is that instead of

Code: Select all

if($sisters) {
foreach ($sisters as $sisterMember) {
they suggest using

Code: Select all

if(count($sisters) > 1) {
foreach ($sisters as $sisterMember) {
And there is some CSS rules defined.

I can confirm that the SEO URL problem also solves if all categories within a brunch (both parents and children) have their SEO keyword set. BTW, in my oppinion, 'SEO address' would be more relevant than 'SEO keyword'.

So, I think this topic is SOLVED.