Post by jeffz2014 » Thu Dec 11, 2014 7:53 am

Version: 2.0.1.0

Problem:
banners disabled in admin in: admin/system/designs/banners still show up-front.

I'm not sure if this is a bug, but surely it is a logical folly, since user disabling banner in the back expects banner not to show, while disabled.

see below:
b1.jpg

b1.jpg (27.81 KiB) Viewed 1819 times

b2.jpg

b2.jpg (22.1 KiB) Viewed 1819 times

Here is a fix:
(for those, who thinks - as me - that disabled means disabled):

#1.
-------------------------------------------------------------------------
Find:
catalog/model/design/banner.php
Add method:

Code: Select all

public function getBannerStatus($banner_id) //jp
    {
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner WHERE banner_id = '" . (int) $banner_id . "'");
	return (int) $query->row['status'];
    }
#2.
-------------------------------------------------------------------------
Find:
catalog/controller/module/banner.php
find code:

Code: Select all

 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/banner.tpl'))
	    {
		return $this->load->view($this->config->get('config_template') . '/template/module/banner.tpl', $data);
	    } else
	    {
		return $this->load->view('default/template/module/banner.tpl', $data);
	    }
replace it with:

Code: Select all

if ($this->model_design_banner->getBannerStatus($setting['banner_id'])!=0) //jp
	{
	    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/banner.tpl'))
	    {
		return $this->load->view($this->config->get('config_template') . '/template/module/banner.tpl', $data);
	    } else
	    {
		return $this->load->view('default/template/module/banner.tpl', $data);
	    }
	}
#3.
-------------------------------------------------------------------------
Find:
catalog/controller/module/carousel.php
find code:

Code: Select all

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/carousel.tpl'))
	    {
		return $this->load->view($this->config->get('config_template') . '/template/module/carousel.tpl', $data);
	    } else
	    {
		return $this->load->view('default/template/module/carousel.tpl', $data);
	    }

replace it with:

Code: Select all

if ($this->model_design_banner->getBannerStatus($setting['banner_id'])!=0) //jp
	{
	    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/carousel.tpl'))
	    {
		return $this->load->view($this->config->get('config_template') . '/template/module/carousel.tpl', $data);
	    } else
	    {
		return $this->load->view('default/template/module/carousel.tpl', $data);
	    }
	}
#4.
-------------------------------------------------------------------------
Find:
catalog/controller/module/slideshow.php
find code:

Code: Select all

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/slideshow.tpl')) {
		return $this->load->view($this->config->get('config_template') . '/template/module/slideshow.tpl', $data);
	    } else {
		return $this->load->view('default/template/module/slideshow.tpl', $data);
	    }
replace it with:

Code: Select all

if ($this->model_design_banner->getBannerStatus($setting['banner_id'])!=0) //jp
	{
	    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/slideshow.tpl')) {
		return $this->load->view($this->config->get('config_template') . '/template/module/slideshow.tpl', $data);
	    } else {
		return $this->load->view('default/template/module/slideshow.tpl', $data);
	    }
	}

Newbie

Posts

Joined
Tue Dec 09, 2014 6:48 am

Post by 528491 » Wed May 18, 2016 10:14 pm

I am perplexed why is this happening. I also use Opencart 2.0.1.0, not sure if this is issue only in this specific version, but yeah, 'disabling' banner should really mean exactly that - disabling a banner from showing up front. Thank you for your solution, will try it now.

Edit:
Actually I found a way that doesn't include any additional coding. However unlogical it might seem, you need to go to Extensions > Modules and enable/disable the banner from there.

New member

Posts

Joined
Tue Apr 02, 2013 6:05 pm
Who is online

Users browsing this forum: No registered users and 10 guests