Post by vinsbg » Wed Jul 09, 2014 2:58 pm

Hi,
firstly I want to apologize if I'm in wrong forum.
I just started with Opencart and my version is 1.5.6, also I have some background with php but not so much .. I trying to put images in sub-categories where is Refine Search. I want to have image above the text. Can someone help me how to do this?

So far I've made changes in my catalog\controller\module\category.php from this

Code: Select all

$children_data[] = array(
	'category_id' => $child['category_id'],
	'name'        => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
	'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
	);		
}
$this->data['categories'][] = array(
	'category_id' => $category['category_id'],
	'name'        => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
	'children'    => $children_data,
	'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
);
to this ( I've added 'image' => $category['image'], )

Code: Select all

$children_data[] = array(
	'category_id' => $child['category_id'],
	'name'        => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
        'image'       => $category['image'],
	'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
);		
}
$this->data['categories'][] = array(
	'category_id' => $category['category_id'],
	'name'        => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
        'image'       => $category['image'],
        'children'    => $children_data,
	'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
);
In catalog\view\theme\MYTHEME\template\product\category.tpl , I've added <img src="http://localhost/image/data/models/<?php echo $categories['image']; ?>" width="100"/> here

Code: Select all

<div class="category-list">

    <?php if (count($categories) <= 5) { ?>
    <ul>
      <?php foreach ($categories as $category) { ?>

      <li>
          <img src="http://localhost/image/data/models/<?php echo $categories['image']; ?>" width="100"/>
          <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
          <hr>
      </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>
          <img src="http://localhost/image/data/models/<?php echo $categories['image']; ?>" width="100"/>
          <a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li>

      <?php } ?>
      <?php } ?>
    </ul>
    <?php } ?>
    <?php } ?>
  </div>
This is the result so far on the attached image. Can someone help me?
p.s. Sorry for my English.

Attachments

sub.jpg

sub.jpg (13.75 KiB) Viewed 4585 times


Newbie

Posts

Joined
Wed Jul 09, 2014 1:55 pm

Post by labeshops » Wed Jul 09, 2014 9:12 pm

I use this mod that does exactly what you are trying to do: http://www.opencart.com/index.php?route ... n_id=12373

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by vinsbg » Wed Jul 09, 2014 9:18 pm

I have 5-6 level deep menu -> category - sub category - sub-sub-sub etc.. I trying to show images for every next level sub-category and as I can see from description this extension wont help me or I'm wrong?
- A specific category: show its subcategories
- (ROOT): Show all top-level categories
- (CURRENT): In Category view, show the subcategories of the CURRENT category (similar to "Refine Search")

Newbie

Posts

Joined
Wed Jul 09, 2014 1:55 pm

Post by labeshops » Wed Jul 09, 2014 9:35 pm

Current would show the current levels subcategories, so even if you have multiple levels, installing it on your category page set to <current> would give you what you are after I think, like:

Main Category - Current displays subcats Level 1
- Level 1 sub - current displays subcats level 2
- level 2 sub - current displays subcats level 3
- level 3 sub - current displays subcats level 4

etc.

I haven't tested this since I never have more than 1 level of subcats, but judging by how it works on mine, it should work as I describe above.

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by vinsbg » Wed Jul 09, 2014 9:45 pm

Ok, I will have this in mind and will ask the developer of the extension.
But I think I'm almost done with this and will try a little bit more to figured out why the images are missing.

Newbie

Posts

Joined
Wed Jul 09, 2014 1:55 pm

Post by grgr » Wed Jul 09, 2014 11:43 pm

Click the see all button below. There is a free little mod I did for refine search images in there somewhere.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by vinsbg » Thu Jul 10, 2014 1:04 am

I've made it. It was my fault :(
I've been edited controller/module/category.php instead of controller/product/category.php .

Newbie

Posts

Joined
Wed Jul 09, 2014 1:55 pm

User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 32 guests