Hello Guys,
version 1.5.5.1
Hi Guys moving to opencart so please understand: and I have been having an issue with this for 3 days now....any help would be appreciated.
I am trying to set my categories and subcategories as follow ( Note I don't care about the left menu or the header)
--> Accessoires
--> Accessoires --> Samsung
--> Accessoires --> Apple
--> Accessoires --> Nokia
--->Accessoires ---> Samsung--> ( Then the Samsung Products eg headphones, batteries...)
--->Accessoires ---> Samsung--> ( Then the Apple Products)
--->Accessoires ---> htc--> ( Then the htc Products)
The problem is my category home page.
When I click on 'Accessoires'( Header)
I would like opencart to show something like in my screenshot.( Force it to show the third sub sub category on home page when I click on the main category
At the moment when I click on the category it shows the sub cat. i hope it is clear.
to make things short would like to show all sub sub categories linked to the main category on my home page ( I don't want to have to click on the sub category to access them) please see screenshot.
Any help would be helpful, or maybe just direct me to an extension, I don't mind paying.
Thanx
version 1.5.5.1
Hi Guys moving to opencart so please understand: and I have been having an issue with this for 3 days now....any help would be appreciated.
I am trying to set my categories and subcategories as follow ( Note I don't care about the left menu or the header)
--> Accessoires
--> Accessoires --> Samsung
--> Accessoires --> Apple
--> Accessoires --> Nokia
--->Accessoires ---> Samsung--> ( Then the Samsung Products eg headphones, batteries...)
--->Accessoires ---> Samsung--> ( Then the Apple Products)
--->Accessoires ---> htc--> ( Then the htc Products)
The problem is my category home page.
When I click on 'Accessoires'( Header)
I would like opencart to show something like in my screenshot.( Force it to show the third sub sub category on home page when I click on the main category
At the moment when I click on the category it shows the sub cat. i hope it is clear.
to make things short would like to show all sub sub categories linked to the main category on my home page ( I don't want to have to click on the sub category to access them) please see screenshot.
Any help would be helpful, or maybe just direct me to an extension, I don't mind paying.
Thanx
Attachments
please see screenshot - openc.jpg (43.76 KiB) Viewed 8663 times
Edit catalog/controller/product/category.php and find:
and replace with:
then edit catalog/view/theme/yourtheme/template/product/category.tpl find:
and replace with:
I think I might have misunderstood, my code is for displaing that way the subcategories on a category page, if you want on homepage you might find a module for that.
Code: Select all
foreach ($results as $result) {
$data = array(
'filter_category_id' => $result['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$this->data['categories'][] = array(
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}
Code: Select all
foreach ($results as $result) {
$subcats = array();
$subresults = $this->model_catalog_category->getCategories($result['category_id']);
foreach ($subresults as $subresult) {
if ($subresult['image']) {
$image = $this->model_tool_image->resize($subresult['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
}
$subcats[] = array(
'name' => $subresult['name'],
'image' => $image,
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . '_' . $subresult['category_id'] . $url)
);
}
$this->data['categories'][] = array(
'name' => $result['name'],
'subcats' => $subcats,
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}
Code: Select all
<?php if ($categories) { ?>
<h2><?php echo $text_refine; ?></h2>
<div class="category-list">
<?php if (count($categories) <= 5) { ?>
<ul>
<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
<?php } ?>
</ul>
<?php } else { ?>
<?php for ($i = 0; $i < count($categories);) { ?>
<ul>
<?php $j = $i + ceil(count($categories) / 4); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($categories[$i])) { ?>
<li><a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
Code: Select all
<?php if ($categories) { ?>
<?php foreach ($categories as $category) { ?>
<h3 style="padding-bottom: 3px; border-bottom: 1px solid #ddd;"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></h3>
<?php if ($category['subcats']) { ?>
<div class="box-product">
<?php foreach ($category['subcats'] as $subcat) { ?>
<div>
<div class="image"><a href="<?php echo $subcat['href']; ?>"><img src="<?php echo $subcat['image']; ?>" title="<?php echo $subcat['name']; ?>" alt="<?php echo $subcat['name']; ?>" /></a></div>
<div class="name"><a href="<?php echo $subcat['href']; ?>"><?php echo $subcat['name']; ?></a></div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
I think I might have misunderstood, my code is for displaing that way the subcategories on a category page, if you want on homepage you might find a module for that.
Just a quick update:
It worked fine ( Using the Sellya template)
But I have another issue now: images for ( sub sub categories are too big) please see screenshot, I believe it has to do with the changes to catalog/controller/product/category.php (everything works fine apart from that size!)
------catalog/controller/product/category.php before---------[/code]
------catalog/controller/product/category.php after---------
-------------------------------------------------
It might be a quick fix or extension fix i don't really mind...really sorry guys but again guys thanx for your understanding especially @florinsith
It worked fine ( Using the Sellya template)
But I have another issue now: images for ( sub sub categories are too big) please see screenshot, I believe it has to do with the changes to catalog/controller/product/category.php (everything works fine apart from that size!)
------catalog/controller/product/category.php before---------
Code: Select all
[code]foreach ($results as $result) {
$data = array(
'filter_category_id' => $result['category_id'],
'filter_sub_category' => true
);
$product_total = $this->model_catalog_product->getTotalProducts($data);
$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'));
$this->data['categories'][] = array(
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url), 'thumb' => $image
);
}
------catalog/controller/product/category.php after---------
Code: Select all
foreach ($results as $result) {
$subcats = array();
$subresults = $this->model_catalog_category->getCategories($result['category_id']);
foreach ($subresults as $subresult) {
if ($subresult['image']) {
$image = $this->model_tool_image->resize($subresult['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
}
$subcats[] = array(
'name' => $subresult['name'],
'image' => $image,
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . '_' . $subresult['category_id'] . $url)
);
}
$this->data['categories'][] = array(
'name' => $result['name'],
'subcats' => $subcats,
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}
It might be a quick fix or extension fix i don't really mind...really sorry guys but again guys thanx for your understanding especially @florinsith
Attachments
openc2.jpg (79.69 KiB) Viewed 8632 times
In this part of the modification:
you can input direct image size like below:
now I change it to 100 by 100 px, you can change the numbers.
Code: Select all
if ($subresult['image']) {
$image = $this->model_tool_image->resize($subresult['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$image = $this->model_tool_image->resize('no_image.jpg', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
}
Code: Select all
if ($subresult['image']) {
$image = $this->model_tool_image->resize($subresult['image'], 100, 100);
} else {
$image = $this->model_tool_image->resize('no_image.jpg', 100, 100);
}
This worked perfectly for my situation, thank you! I was wondering if there was a conditional statement that could be added to exclude certain pages from showing the subcats. Thank you.
Who is online
Users browsing this forum: No registered users and 19 guests