Page 1 of 1

Footer module for opencart 1.5

Posted: Sat Jun 25, 2011 8:56 pm
by pixel
This modification adds footer module in footer file,
First, open catalog/controller/common/footer.php -file
and change/replace all code to this

Code: Select all

<?php  
class ControllerCommonFooter extends Controller {
	protected function index() {
		$this->language->load('common/footer');
		
		$this->data['text_information'] = $this->language->get('text_information');
		$this->data['text_service'] = $this->language->get('text_service');
		$this->data['text_extra'] = $this->language->get('text_extra');
		$this->data['text_account'] = $this->language->get('text_account');
		$this->data['text_contact'] = $this->language->get('text_contact');
		$this->data['text_return'] = $this->language->get('text_return');
    	$this->data['text_sitemap'] = $this->language->get('text_sitemap');
		$this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
		$this->data['text_voucher'] = $this->language->get('text_voucher');
		$this->data['text_affiliate'] = $this->language->get('text_affiliate');
		$this->data['text_special'] = $this->language->get('text_special');
		$this->data['text_login'] = $this->language->get('text_login');
		$this->data['text_order'] = $this->language->get('text_order');
		$this->data['text_wishlist'] = $this->language->get('text_wishlist');
		$this->data['text_newsletter'] = $this->language->get('text_newsletter');
		
		$this->load->model('catalog/information');
		
		$this->data['informations'] = array();

		foreach ($this->model_catalog_information->getInformations() as $result) {
      		$this->data['informations'][] = array(
        		'title' => $result['title'],
	    		'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
      		);
    	}

		$this->data['contact'] = $this->url->link('information/contact');
		$this->data['return'] = $this->url->link('account/return/insert', '', 'SSL');
    	$this->data['sitemap'] = $this->url->link('information/sitemap');
		$this->data['manufacturer'] = $this->url->link('product/manufacturer', '', 'SSL');
		$this->data['voucher'] = $this->url->link('checkout/voucher', '', 'SSL');
		$this->data['affiliate'] = $this->url->link('affiliate/account', '', 'SSL');
		$this->data['special'] = $this->url->link('product/special');
		$this->data['login'] = $this->url->link('account/login', '', 'SSL');
		$this->data['order'] = $this->url->link('account/order', '', 'SSL');
		$this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
		$this->data['newsletter'] = $this->url->link('account/newsletter', '', 'SSL');		

		$this->data['powered'] = sprintf($this->language->get('text_powered'), $this->config->get('config_name'), date('Y', time()));
		
		$this->load->model('design/layout');
		$this->load->model('catalog/category');
		$this->load->model('catalog/product');
		$this->load->model('catalog/information');
		
		if (isset($this->request->get['route'])) {
			$route = $this->request->get['route'];
		} else {
			$route = 'common/home';
		}
		
		$layout_id = 0;
		
		if (substr($route, 0, 16) == 'product/category' && isset($this->request->get['path'])) {
			$path = explode('_', (string)$this->request->get['path']);
				
			$layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));			
		}
		
		if (substr($route, 0, 16) == 'product/product' && isset($this->request->get['product_id'])) {
			$layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
		}
		
		if (substr($route, 0, 16) == 'product/information' && isset($this->request->get['information_id'])) {
			$layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
		}
		
		if (!$layout_id) {
			$layout_id = $this->model_design_layout->getLayout($route);
		}
						
		if (!$layout_id) {
			$layout_id = $this->config->get('config_layout_id');
		}

		$module_data = array();
		
		$this->load->model('setting/extension');
		
		$extensions = $this->model_setting_extension->getExtensions('module');		
		
		foreach ($extensions as $extension) {
			$modules = explode(',', $this->config->get($extension['code'] . '_module'));
		
			foreach ($modules as $module) {
				if ($this->config->get($extension['code'] . '_' . $module . '_layout_id') == $layout_id && $this->config->get($extension['code'] . '_' . $module . '_position') == 'content_footer' && $this->config->get($extension['code'] . '_' . $module . '_status')) {
					$module_data[] = array(
						'code'       => $extension['code'],
						'module'     => $module,
						'sort_order' => $this->config->get($extension['code'] . '_' . $module . '_sort_order')
					);				
				}
			}
		}
		
		$sort_order = array(); 
	  
		foreach ($module_data as $key => $value) {
      		$sort_order[$key] = $value['sort_order'];
    	}
		
		array_multisort($sort_order, SORT_ASC, $module_data);
		
		$this->data['modules'] = array();
		
		foreach ($module_data as $module) {
			$module = $this->getChild('module/' . $module['code'], $module['module']);
			
			if ($module) {
				$this->data['modules'][] = $module;
			}
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/footer.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/footer.tpl';
		} else {
			$this->template = 'default/template/common/footer.tpl';
		}
		
		$this->render();
	}
}
?>
after that open catalog/view/theme/default/template/common/footer.tpl file and add

Code: Select all

  <?php foreach ($modules as $module) { ?>
<?php echo $module; ?>
<?php } ?>
Now for use this open admin/controller/module/mymodule.php and add after

Code: Select all

$this->data['text_content_bottom'] = $this->language->get('text_content_bottom');				    $this->data['text_content_footer'] = $this->language->get('text_content_footer');		
and in admin/view/template/module/mymodule.tpl this code after

Code: Select all

                <?php if (${'mymodule_' . $module . '_position'} == 'content_bottom') { ?>
                <option value="content_bottom" selected="selected"><?php echo $text_content_bottom; ?></option>
                <?php } else { ?>
                <option value="content_bottom"><?php echo $text_content_bottom; ?></option>
                <?php } ?>     

Code: Select all

<?php if (${'mymodule_' . $module . '_position'} == 'content_footer') { ?>
                <option value="content_footer" selected="selected"><?php echo $text_content_footer; ?></option>
                <?php } else { ?>
                <option value="content_footer"><?php echo $text_content_footer; ?></option>
                <?php } ?> 

Re: Footer module for opencart 1.5

Posted: Sat Jun 25, 2011 9:10 pm
by pixel
If you have a custom theme you must change footer.tpl , If you want this change to be possible

Re: Footer module for opencart 1.5

Posted: Sat Jun 25, 2011 10:09 pm
by pixel
This modification adds footer and header module in footer and header file.
The header and footer file will be replaced whit the new ones.
for download this go to
http://www.opencart.com/index.php?route ... on_id=2434

Re: Footer module for opencart 1.5

Posted: Sat Jul 09, 2011 4:26 am
by maciek
OK, I have uploaded the files but what now. How to use it? Is there any install instruction?
There is nothing like header or footer in extension->modules section.
oc 1.5.0.5

Re: Footer module for opencart 1.5

Posted: Sun Jul 24, 2011 12:21 am
by karlpers
Will this work on 1.5.1?