How to put the Category module in the footer in OpenCart without editing the source code

I’ve been busy setting up a shop recently, but I’ve now started developing themes for OpenCart again. I’ve sorted out the problems with my post on how to add the Information module in the footer in OpenCart and have applied the same technique to add the Category module in the footer in OpenCart without editing the source code.

The principle is exactly the same as listing the Information in the footer. Firstly you need to load the category model. You can then run the getCategories function and output the results. In order to work with SEO URLs you also need to load the SEO URL tool. Finally, in order for the heading to work with other languages you also need to load the category language data.

Anyway, here’s the code. Just stick it in your footer and enjoy:

<?php
$this->language->load('module/category');
$heading_title = $this->language->get('heading_title');
?>
<h3><?php echo $heading_title ?></h3>
<?php
$this->load->model('tool/seo_url');
$this->load->model('catalog/category');
$results = $this->model_catalog_category->getCategories();
if ($results) {$output = '<ul>';}
foreach ($results as $result) {
$new_path = $result['category_id'];
$unrewritten = HTTP_SERVER.'index.php?route=product/category&path=' . $new_path;
$rewritten = $this->model_tool_seo_url->rewrite($unrewritten);
$output .= '<li><a href="'.str_replace('&', '&amp;', $rewritten).'">'.$result['name'].'</a></li>';
}
if ($results) {$output .= '</ul>';}
echo $output;
?>

This entry was posted in OpenCart Mods. Bookmark the permalink.

3 Responses to How to put the Category module in the footer in OpenCart without editing the source code

  1. Hello, I just started 3 weeks ago learning and using Opencart. I have some basic questions and was wondering if there was a manual, or some literature on this software to help guide me with what to do next and how to do this. If I wanted to remove the Paypal logo on the bottom, and ad a verified merchant from authorize.net in that weird code, how can I remove one and add the other? Where does that code go in Opencart? I want to put a facebook like badge, but cant figure out where to put the code. Help me please. Thank you so much

    Jared

  2. Craig says:

    Hi Jared, there’s a documentation section on the OpenCart website which has a lot of useful information. You can find it here http://www.opencart.com/index.php?route=documentation/documentation. You’ll also see there that you can buy a Beginner’s Guide. There’s also a lot of useful information in the Forums.

    As for changing the Paypal logo, you can edit the footer.tpl file in your templates folder. It’s in the template > common folder. And I see you’ve now added a Facebook Like button, so well done.

    Craig

  3. Pagetopixel says:

    Worked perfect. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>