Post by kotysoft » Fri Mar 26, 2010 4:49 am

Hi,

I'd like to show subcategories ALWAYS in categories module like when you click on main category. But i would like the complete "tree" in side module. How can i do it?

Thanks for answers,
Kotysoft
Last edited by i2Paq on Thu Oct 14, 2010 12:00 am, edited 1 time in total.
Reason: Topic moved

New member

Posts

Joined
Sat Feb 06, 2010 10:01 pm

Post by scot80 » Fri Mar 26, 2010 7:07 am

open /catalog/controller/module/category.php

find:

Code: Select all

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

Code: Select all

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

Active Member

Posts

Joined
Fri Nov 06, 2009 12:14 am
Location - Germany

Post by The Alchemist » Tue Mar 30, 2010 12:58 am

Any examples on what this looks like? Im not sure if this is what I am looking for myself

User avatar
Active Member

Posts

Joined
Sun Nov 22, 2009 11:04 am

Post by norbert » Fri Apr 23, 2010 8:06 pm

thank you so much! it works perfectly.

Newbie

Posts

Joined
Fri Apr 23, 2010 8:00 pm

Post by opensc010 » Wed Oct 13, 2010 12:30 am

The above method expands my ALL subcategories 4 levels deep. Please anybody can tell me how to expand ONLY 1 level deep (to look like this: main category->sub category)?

I also need that subcategories of 3 and 4 levels disappear from category block but still be visible in home page?

Really appreciate your advices!

Newbie

Posts

Joined
Wed Oct 13, 2010 12:27 am

Post by jty » Fri Oct 15, 2010 9:10 pm

opensc010 wrote:The above method expands my ALL subcategories 4 levels deep. Please anybody can tell me how to expand ONLY 1 level deep (to look like this: main category->sub category)?
Is this your answer ?
http://forum.opencart.com/viewtopic.php ... t=0#p38045

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by opensc010 » Sun Oct 17, 2010 4:24 am

jty wrote:
opensc010 wrote:The above method expands my ALL subcategories 4 levels deep. Please anybody can tell me how to expand ONLY 1 level deep (to look like this: main category->sub category)?
Is this your answer ?
http://forum.opencart.com/viewtopic.php ... t=0#p38045
That is exactly what i was looking for. Thank you very much!

Newbie

Posts

Joined
Wed Oct 13, 2010 12:27 am

Post by roland414 » Tue Feb 15, 2011 1:55 pm

Thanks for the post

always for me


Newbie

Posts

Joined
Tue Feb 15, 2011 1:15 pm

Post by itmanvn » Tue Apr 24, 2012 6:36 pm

noted with thanks

Newbie

Posts

Joined
Thu Jan 13, 2011 12:57 pm

Post by stamasar » Mon Oct 07, 2013 10:38 pm

scot80 wrote:open /catalog/controller/module/category.php

find:

Code: Select all

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

Code: Select all

$children = $this->getCategories($result['category_id'], $new_path);
Hi!
Thes lines of code don`t exist with the same structure on v1.5.6.
Any suggestions how to achieve the same results using opencart 1.5.6.?
Thanks.

Newbie

Posts

Joined
Fri Aug 09, 2013 4:35 pm

Post by cases4u » Mon Nov 25, 2013 9:22 am

Hi

In 1.5.6 open catalog/controller/module/category.php

Goto Line 32 -

Code: Select all

$categories = $this->model_catalog_category->getCategories(0);
Change the 0 at the end which is the parent id to which ever sub-categories you wish to display.

Any problems, reply back.

Thanks

Newbie

Posts

Joined
Thu Oct 24, 2013 9:50 pm

Post by stamasar » Mon Nov 25, 2013 5:15 pm

Hi again!
I wish to show all the subcategories of the selected (sub)category.
For example:
CATEGORY1
_____SUBCATEGORY OF CATEGORY1
__________ALL THE SUBACTEGORIES OF SUBCATEGORY.

Many thanks

Newbie

Posts

Joined
Fri Aug 09, 2013 4:35 pm

Post by Nikolozi » Sun Nov 23, 2014 4:43 pm

While template/module/category.tpl looks like this:

<div class="list-group">
<?php foreach ($categories as $category) { ?>
<?php if ($category['category_id'] == $category_id) { ?>
<a href="<?php echo $category['href']; ?>" class="list-group-item active"><?php echo $category['name']; ?></a>
<?php if ($category['children']) { ?>
<?php foreach ($category['children'] as $child) { ?>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item active">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } else { ?>
<a href="<?php echo $category['href']; ?>" class="list-group-item"><?php echo $category['name']; ?></a>
<?php } ?>
<?php } ?>
</div>

Change it to:

<div class="list-group">
<?php $zara=true; foreach ($categories as $category) { ?>
<?php if ($category['category_id'] == $category_id) { ?>

<a href="<?php echo $category['href']; ?>" class="list-group-item active"><?php echo $category['name']; ?></a>
<?php if ($category['children']) { ?>
<?php foreach ($category['children'] as $child) { ?>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item active">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } else if ($category_id==NULL) { ?>
<a href="<?php echo $category['href']; ?>" class="list-group-item"><?php echo $category['name']; ?></a>
<?php if ($category['children']) { ?>
<?php foreach ($category['children'] as $child) { ?>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item active">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item">&nbsp;&nbsp;&nbsp;- <?php echo $child['name']; ?></a>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
</div>

and it will give you the first level subcategories under the parents on the homepage. This works with the last version of OpenCart. You may tweak this a little to get deeper subcategories displayed as well.

Newbie

Posts

Joined
Sun Nov 09, 2014 5:31 pm

Post by mavroudis » Fri Jan 09, 2015 7:37 pm

Hi, is it possible to do the same thing in OC 2.0.0?
Because I get this:
Notice: Undefined index: children in catalog\view\theme\default\template\product\category.tpl on line 65"

Thanks

Newbie

Posts

Joined
Fri Apr 26, 2013 12:06 am

Post by likhamahudda » Mon Mar 28, 2016 6:41 pm

Thanks Really nice
Working fine
these code will all category and subcategory

Newbie

Posts

Joined
Mon Mar 28, 2016 6:39 pm
Who is online

Users browsing this forum: No registered users and 4 guests