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

Not being a programmer, it’s taken me a while, but I’ve started to work out how OpenCart works. So when I decided I wanted to try and put the Information details in the footer without editing any source code it wasn’t too hard.

Firstly you need to load the SEO URL tool (incase people are using SEO URLs, which they should be) and you need to load the Information language module (to allow for different language options). After that you can use the getInformations() function to access most of the Information module.

getInformations() doesn’t include “Contact Us” or “Site Map” for some reason, so you have to add them at the end. Apart from that, it’s pretty straightforward. Here’s the code:

Edit: This now includes adaptations as suggested in the comments following the article. That’ll teach me to post before I’ve fully tested!

Second edit: This now doesn’t include the adaptations as suggested in the comments because I worked out how to make it work without having the Information module enabled. This should work perfectly now.

<?php
$this->language->load('module/information');
$heading_title = $this->language->get('heading_title');
?>
<h3><?php echo $heading_title ?></h3>
<ul>
<?php
$this->load->model('tool/seo_url');
$this->load->model('catalog/information');
$output = '';
$results = $this->model_catalog_information->getInformations();
foreach ($results as $result) {
$output .= '<li>';
$new_path = $result['information_id'];
$unrewritten = HTTP_SERVER.'index.php?route=information/information&information_id='.$new_path;
$rewritten = $this->model_tool_seo_url->rewrite($unrewritten);
$output .= '<a href="'.str_replace('&', '&amp;', $rewritten).'">'.$result['title'].'</a>';
$output .= '</li>';
}
echo $output;
$text_contact = $this->language->get('text_contact');
$text_sitemap = $this->language->get('text_sitemap');
?>
<li><a href="<?php HTTP_SERVER ?>index.php?route=information/contact"><?php echo $text_contact ?></a></li>
<li><a href="<?php HTTP_SERVER ?>index.php?route=information/sitemap"><?php echo $text_sitemap ?></a></li>
</ul>

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

13 Responses to How to put the Information module in the footer in OpenCart without editing the source code

  1. Heather says:

    Just dropping a note to say you are amazing! This and your technique you shared for adding a list of categories in the header have been a great help. Thanks!

  2. Heather says:

    Oh, I did notice though that if you disable the Information module from showing in your sidebar this will produce an error:
    Fatal error: Call to a member function getInformations() on a non-object in C:\wamp\www\openstore\catalog\view\theme\VintageAffair\template\common\footer.tpl on line 10

    So I’m guessing you have to leave the module actually enabled. I didn’t necessarily want this information displayed in two places on my theme so I only applied a simple fix of setting the module to appear in my right sidebar (which I don’t have visible in my theme).

  3. Craig says:

    Hi Heather, thanks for your comments. I hadn’t noticed the bug with disabling the information module but I’ll look into it when I get a moment and let you know if I find a better fix.

  4. dotzoki says:

    There is an error if you disable information module in Opencart administration.

    This should work without error.

    <ul>
    <?php
    load->model('tool/seo_url');
    $this->language->load('module/information');
    $output = '';
    $modelCatalogInfo = $this->model_catalog_information;
    if (isset($modelCatalogInfo)) {
    $results = $modelCatalogInfo->getInformations();
    foreach ($results as $result) {
    $output .= '';
    $new_path = $result['information_id'];
    $unrewritten = HTTP_SERVER.'index.php?route=information/information&information_id='.$new_path;
    $rewritten = $this->model_tool_seo_url->rewrite($unrewritten);
    $output .= '<a href="'.str_replace('&', '&amp;', $rewritten).'">'.$result['title'].'</a>';
    $output .= '';
    }
    }
    echo $output;
    $text_contact = $this->language->get('text_contact');
    $text_sitemap = $this->language->get('text_sitemap');
    ?>
    <li><a href="<?php echo HTTP_SERVER . 'index.php?route=information/contact'; ?>"><?php echo $text_contact; ?></a></li>
    <li><a href="<?php echo HTTP_SERVER . 'index.php?route=information/sitemap'; ?>"><?php echo $text_sitemap; ?></a></li>
    </ul>

  5. dotzoki says:

    well code tag ate some of my tags :) you should fix it.

  6. Craig says:

    Thanks dotzoki, have fixed the code (I think). When I get a moment I’ll give it a test, but it looks good to me. Cheers.

  7. Simon says:

    Almost ;)

    I won’t post the whole code but change this and it works (and with items in li)


    $this->load->model('tool/seo_url');

    And for the items in li:

    $output .= '';

  8. Craig says:

    Thanks Simon, I’d yet to test it. It’s fixed now. Also had to move the end of the first loop to the end to catch the $output of the contact and sitemap. I’ve updated it in the main article and tested this time ;)

  9. Craig says:

    Hey all, I’ve now had a chance to look at this properly. I forgot to load the Information module model first. Doh! I’ve fixed the code. This should now work perfectly without you having to enable the Information module in the admin section. Apologies for being a bit rubbish, and a bit too busy to have a look at it before now.

  10. Pingback: How to put the Category module in the footer in OpenCart without editing the source code | Craig Murray

  11. ash says:

    cheers thanks!!!

  12. Emily says:

    This is a great solution! Just wondering, what mods would have to be made to exclude a couple of information pages. I looked at your category exclusion post and tried to apply the same method but I kept getting syntax errors as I’m not a programmers. Any suggestions?

  13. Craig says:

    I’ve not tried this Emily, but there’s a new feature been built in to Opencart. In the Admin section, if you set the sort order of an Information page to -1 it doesn’t show in the list. I’m guessing it will be the same for my code.

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>