In -- controller > common > home.php -- I added it around line 25, right under this portion
Code: Select all
if (!$this->config->get('config_store_id')) {
$this->data['welcome'] = html_entity_decode($this->config->get('config_description_' . $this->config->get('config_language_id')), ENT_QUOTES, 'UTF-8');
} else {
$store_info = $this->model_setting_store->getStore($this->config->get('config_store_id'));
if ($store_info) {
$this->data['welcome'] = html_entity_decode($store_info['description'], ENT_QUOTES, 'UTF-8');
} else {
$this->data['welcome'] = '';
}
}
Code: Select all
$this->load->model('catalog/category');
$this->data['categories'] = $this->model_catalog_category->getCategories(0);
Code: Select all
<ul id="catalog-nav">
<?php foreach($categories as $category): ?>
<?php // print_r($category); ?>
<li style="text-indent: 0;">
<a href="index.php?route=product/category&path=<?php echo $category['category_id'] ?>">
<img src="/store/image/<?php echo $category['image'] ?>" style="border:0;">
</a>
</li>
<?php endforeach; ?>
</ul>
I also implemented a lookup for SEO Friendly URLs, but it can be pretty database intensive for larger sites, so if anyone knows of a better way to doing this lookup then my way, please feel free to post it!
I added this to the controller, just beneath the first snippet.
Code: Select all
$cat_count = 0;
foreach($this->data['categories'] as $category){
$seo_url_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'category_id=" . $category['category_id'] . "'");
if ($seo_url_query->num_rows) {
$this->data['categories'][$cat_count]['seo_keyword'] = $seo_url_query->row['keyword'];
}
$cat_count++;
}
Then, for the view, replace the previous snippet with this one.
Code: Select all
<ul id="catalog-nav">
<?php foreach($categories as $category): ?>
<?php // print_r($category); ?>
<li style="text-indent: 0;">
<?php if(isset($category['seo_keyword'])){ ?>
<a href="/store/<?php echo $category['seo_keyword'] ?>/">
<?php } else { ?>
<a href="index.php?route=product/category&path=<?php echo $category['category_id'] ?>">
<?php } ?>
<img src="/store/image/<?php echo $category['image'] ?>" style="border:0;">
</a>
</li>
<?php endforeach; ?>
</ul>
Happy hacking!