Post by Cabsie » Sun May 19, 2013 5:06 am

Hi All,
I have updated my cart to show a different header on the home page using this change within "catalog/controller/common/header.php"

the Home page is using a different header to the rest of the site (header_home.tpl opposed to header.tpl)

Code: Select all

if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && ($this->request->get['route'] == 'common/home'))) {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_home.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header_home.tpl';
    } else {
        $this->template = 'default/template/common/header_home.tpl';
    }
} else {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
    } else {
        $this->template = 'default/template/common/header.tpl';
    }
} 
What i am looking to do is change it so this alternative header (header_home) also applies to the information page (information/information).
Basically the code says: if the page is common/home then use the alternative header. I want it to use the same alternative header if it is common/home or information/information.
Any idea's how I can change this so it applies the same logic to more than one page?
Thanks,

Newbie

Posts

Joined
Sun May 19, 2013 4:51 am

Post by Cabsie » Sun May 19, 2013 8:03 pm

I have worked it out.
I just had to insert an extra "or statement" || in the first line:

Code: Select all

if (!isset($this->request->get['route']) || (isset($this->request->get['route']) && ($this->request->get['route'] == 'common/home')) || (isset($this->request->get['route']) && ($this->request->get['route'] == 'information/information'))) {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_home.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header_home.tpl';
    } else {
        $this->template = 'default/template/common/header_home.tpl';
    }
} else {
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
        $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
    } else {
        $this->template = 'default/template/common/header.tpl';
    }
}

Newbie

Posts

Joined
Sun May 19, 2013 4:51 am

Post by Buz » Wed May 21, 2014 12:31 am

Thanks for posting, you've solved my needs, too!

The only bit I modified, just to make it a bit more legible, is employing a temp variable:

Code: Select all

	// get the route, default to HOME.
	$ocRoute = isset($this->request->get['route']) ? $this->request->get['route'] : 'common/home';
	if ($ocRoute == 'common/home') {
		// do stuff

Buz
Newbie

Posts

Joined
Sat May 10, 2014 1:38 am
Who is online

Users browsing this forum: No registered users and 26 guests