Post by gunner86 » Sat Sep 09, 2017 12:39 am

i want to use different css on BODY , at the store page and at the product and category pages ... how can i make that ? thanks ...

Active Member

Posts

Joined
Wed Jul 09, 2014 3:43 pm

Post by DigitCart » Sat Sep 09, 2017 12:50 am

Hi,
In Opencart 2.x and 3.x body has different class in different pages. You can use it in Opencart 1 too.
code from the catalog\controller\common\header.php OC2.3:

Code: Select all

// For page specific css
if (isset($this->request->get['route'])) {
	if (isset($this->request->get['product_id'])) {
		$class = '-' . $this->request->get['product_id'];
	} elseif (isset($this->request->get['path'])) {
		$class = '-' . $this->request->get['path'];
	} elseif (isset($this->request->get['manufacturer_id'])) {
		$class = '-' . $this->request->get['manufacturer_id'];
	} elseif (isset($this->request->get['information_id'])) {
		$class = '-' . $this->request->get['information_id'];
	} else {
		$class = '';
	}

	$data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
} else {
	$data['class'] = 'common-home';
}
and catalog\view\theme\default\template\common\header.tpl:

Code: Select all

<body class="<?php echo $class; ?>">

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by gunner86 » Sat Sep 09, 2017 1:06 am

do i have to copy them to header.php and the other to header.tpl as you write ? i am not good at using codes correctly ... please if you can explain a little more i will be so glad . thanks ...

Active Member

Posts

Joined
Wed Jul 09, 2014 3:43 pm

Post by DigitCart » Sat Sep 09, 2017 1:31 am

I think my description in the previous post is enough.
If you have OpenCart 2.x package, look at the files I mentioned.
If you use custom theme, edit your custom theme instead of the default template.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by gunner86 » Sat Sep 09, 2017 2:27 am

i have not opencart 2 ... i use 1.5.6.4 ... and if you think that your desc. is enough what can i say ... thanks ...

Active Member

Posts

Joined
Wed Jul 09, 2014 3:43 pm

Post by gunner86 » Wed Sep 13, 2017 9:10 pm

i saw that the problem is not the only one .
my body like this in the header.tpl
<body>
<div id="wrap1">
<div id="wrap2"></div>
<div id="wrap3"></div>
<div id="wrap4"></div>
<div id="wrap5"></div>
<div id="wrap6"> </div>

but on catalog and product page i will need , maybe 2 or 3 of them ... what kind of change i have to do for that ... thanks

( https://www.opencart.com/index.php?rout ... earch=body )
i install this extenison but i think it is only about css ...

Active Member

Posts

Joined
Wed Jul 09, 2014 3:43 pm

Post by IP_CAM » Thu Sep 14, 2017 2:12 am

This is, what will be shown in a 1.5.6.x Version, after implementing the Code into the header.php file,
it's suddenly complaining about an unexpected 'end-php' ?> TAG on the Page End.

Code: Select all

Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION) in /home/jacobch/www/ebikes_li/shop/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 221
and after removing this PHP END Tag (still required in 1.5.x Versions!), it displays this:

Code: Select all

Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION) in /home/jacobch/www/ebikes_li/shop/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 221
meaning, that the Code from v.2.x Versions in the header.php file does not work, as coded,
since 1.5.6.x Versions still use $this->data instead of $data !
---
So, I implemented this Code, found in PEKU's famous V.2-themed OpenCart EDGE 1.5.6.5, to
make it work error-free.
---
The Content will replace anything, what comes below this Sectiion:

Code: Select all

'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
		);
	}
}
with this:

Code: Select all

if (isset($this->request->get['route'])) {
if (isset($this->request->get['product_id'])) {
	$class = '-' . $this->request->get['product_id'];
} elseif (isset($this->request->get['path'])) {
	$class = '-' . $this->request->get['path'];
} elseif (isset($this->request->get['manufacturer_id'])) {
	$class = '-' . $this->request->get['manufacturer_id'];
} else {
	$class = '';
}
	$this->data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
} else {
	$this->data['class'] = 'common-home';
}
$this->children = array(
	'module/language',
	'module/currency',
	'module/cart'
);
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';
}

$this->render();
}
}
?>
And one now just has to find out, where to place the COMMAND, to exchange the Default Style
with the Custom Style, to be used in specific Sections. ???
Untested yet, but possibly, by creating a product-category-34 CLASS Section
in the stylesheet.css File, to match the Page(s), where changes are to be placed.
In this case, the <body class="product-category-34"> Link in the Browser-Source.
But, to be honest, I don't know (yet), I could be faaaar off !... :choke: :laugh:
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 273 guests