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
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
Reason: Topic moved
open /catalog/controller/module/category.php
find:
change to this:
find:
Code: Select all
if ($category_id == $result['category_id']) {
$children = $this->getCategories($result['category_id'], $new_path);
}
Code: Select all
$children = $this->getCategories($result['category_id'], $new_path);
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!
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!
Is this your answer ?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)?
http://forum.opencart.com/viewtopic.php ... t=0#p38045
That is exactly what i was looking for. Thank you very much!jty wrote:Is this your answer ?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)?
http://forum.opencart.com/viewtopic.php ... t=0#p38045
Hi!scot80 wrote:open /catalog/controller/module/category.php
find:change to this:Code: Select all
if ($category_id == $result['category_id']) { $children = $this->getCategories($result['category_id'], $new_path); }
Code: Select all
$children = $this->getCategories($result['category_id'], $new_path);
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.
Hi
In 1.5.6 open catalog/controller/module/category.php
Goto Line 32 -
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
In 1.5.6 open catalog/controller/module/category.php
Goto Line 32 -
Code: Select all
$categories = $this->model_catalog_category->getCategories(0);
Any problems, reply back.
Thanks
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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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.
<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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?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.
Who is online
Users browsing this forum: No registered users and 4 guests