Post by mattys » Mon Jul 22, 2019 3:52 pm

In OC2 the body tag included styling/classes, which meant you could customise the page with css, e.g. <body class="product-product-1572">. It was a fantastic feature. This is not available for OC3, not my OC3 anyway (although i could be doing something wrong or the site may not have upgraded properly).

The OC3 website im working on is here https://www.logo-golfballs.co.uk/titlei ... f-umbrella, as you can see via view source, no body tag classes.

I cannot find any other ways to style product or category pages easily, and i cannot find any other code/tags which serves the same purpose (maybe a customised wrapping div). I have seen this kind of post before, where it is something so obvious, but if there is a really obvious solution, i am being dumb, and need help!

I need to be able display the red text on this page https://www.logo-golfballs.co.uk/titlei ... f-umbrella 'Please make sure the colour...' for certain products only and in the exact location it is in.

If custom styling is no longer possible, if anyone can suggest another solution, it would be much appreciated.

Thanks

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by DigitCart » Mon Jul 22, 2019 5:39 pm

Hi
From OC 2.3:
catalog\controller\common\header.php

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';
}
catalog\view\theme\default\template\common\header.tpl

Code: Select all

<body class="<?php echo $class; ?>">
For OpenCart 3.0 the second file should be:
catalog\view\theme\default\template\common\header.twig

Code: Select all

<body class="{{ class }}">

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by letxobnav » Mon Jul 22, 2019 5:55 pm

You could use one of the existing fields in the product table which you are not using:

EAN
UPC
JAN
MPN
ISBN
etc.

put that text with markup in one of those fields in admin for those products, remove the field label in the product.twig or put another label in your language file, and it will display there.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by mattys » Mon Jul 22, 2019 9:59 pm

Hi DigitCart

Thanks for posting the code suggestions.

I had seen this header code before for OC 2, and i did try it, but it did not work with

Code: Select all

<body class="<?php echo $body_class; ?>">
in catalog/view/theme/YOUR_THEME_NAME/template/common/header.tpl.

So, when i saw your code suggestions for OC3 body tag

Code: Select all

<body class="{{ class }}">
, i thought, yes, this may work, but alas no, it doesn't, not for me anyway, and am using default. I just see

Code: Select all

<body class="">
.

I have cleared cache via dashboard and also refreshed mods several times and Ctrl F5 a few times.

If you have any idea why it isn't working, i'm all ears!

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by mattys » Mon Jul 22, 2019 10:01 pm

Hi letxobnav

i will look at your suggestion as looks like may be only way to do, but i would much rather be able to get per product/category styling sorted, makes so much easier.

Thank you.

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by mattys » Mon Jul 22, 2019 10:05 pm

...plus, im not sure that i will be able to place the text in the place it needs to be using fields https://www.logo-golfballs.co.uk/callaw ... hrome-soft

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by letxobnav » Mon Jul 22, 2019 10:31 pm

pick a product, fill those fields in admin for that product under data and see where they show on the page.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by DigitCart » Mon Jul 22, 2019 10:41 pm

Hi
You may need to refresh the modifications in admin panel / extensions / modifications

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by mattys » Mon Jul 22, 2019 10:52 pm

i can assure you, everything refreshed, cleared, refreshed again, then refreshed a couple more times, then a couple more times after that, and then maybe a couple for luck :)

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by mattys » Mon Jul 22, 2019 11:04 pm

letxobnav - thanks for your suggestions with this, but this solution involves too many core file edits https://stackoverflow.com/questions/554 ... -opencart3, and then have to increase character length of field viewtopic.php?t=139528, which includes over 5 different file edits. only option now is to create a custom extension. wish me luck :-\

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by by mona » Tue Jul 23, 2019 3:01 am

This extension will do that
https://www.opencart.com/index.php?rout ... n_id=26852

Basically this will enable you to choose any product / category / layout - or exclude any product / category / layout
You can just create an 'empty' module called “styling” add an empty row (to enable the module) add custom css styling for that specific page and add it to layouts, it will add the styling to that specify page or pages as you wish ..

Oh and you can add mods, create galleries, add links, advertising banners, colour page changes, headers etc etc etc with it also .. I like flexibility!

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Tue Jul 23, 2019 3:14 am

by mona wrote:
Tue Jul 23, 2019 3:01 am
This extension will do that
https://www.opencart.com/index.php?rout ... n_id=26852
And no admin demo...

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by by mona » Tue Jul 23, 2019 3:22 am

xxvirusxx wrote:
Tue Jul 23, 2019 3:14 am
by mona wrote:
Tue Jul 23, 2019 3:01 am
This extension will do that
https://www.opencart.com/index.php?rout ... n_id=26852
And no admin demo...
No demo, I tried that once - once bitten twice shy .. would you like I create a temporary one just for you :)

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by xxvirusxx » Tue Jul 23, 2019 3:29 am

For me no, but maybe for @mattys :)

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by mattys » Mon Jul 29, 2019 6:06 pm

Hi Mona

Thanks for posting, but i would like a simpler, specific and targeted solution, which i still haven't found yet, and am still thinking it will something straight forward.

If anyone has any ideas how i can style individual products/category pages etc, let me know.

Maybe you can spot an error with code solutions suggested already, as they don't work, or any suggestion really.

Basically, i need to hide the red text here https://www.logo-golfballs.co.uk/callaw ... hrome-soft under product options (code has been added to theme file) for certain products.

Thanks

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by letxobnav » Mon Jul 29, 2019 7:19 pm

You are confusing.

first you wanted to be able to display
This product includes a one-time fee of £30.00
for certain products


now you want to be able to hide
Please make sure the colour quantities here don't exceed the Quantity selected in the drop down menu above. For example, if you require 18 doz golf balls, choose 12 - 24 doz. If this is not correct your order may be delayed. Please refer to the pricing table.
for certain products which is in itself confusing for customers specifically, why don't you do the check yourself?

and what has all this to do with styling the body tag?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by mattys » Mon Jul 29, 2019 7:31 pm

Hi letxobnav

Please re read my post.

I never ever mentioned this text on this post - 'This product includes a one-time fee of £30.00'.

Right from the start of the post I have made it VERY clear that this is the text I would like to hide for some products:

'Please make sure the colour...'

I'm not sure what the rest of you post is getting at.

I would just like to be able to add classes to the body tag as i believe this is the best way to style product pages, categories, etc.

It's actually a no brainer.

But thanks for your input.

Matt

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by letxobnav » Mon Jul 29, 2019 10:17 pm

ah, I got the wrong red text then.
It's actually a no brainer.
true, no brain involved there.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by mattys » Mon Jul 29, 2019 10:20 pm

:D no problem

New member

Posts

Joined
Thu Apr 26, 2012 4:51 pm

Post by DigitCart » Mon Jul 29, 2019 11:24 pm

Hi
While the suggestion that I posted earlier should work, you can also use {{ product_id }} in product.twig:

Code: Select all

<p class="quantitymessage quantitymessage-{{ product_id }}">your text</p>

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm

Who is online

Users browsing this forum: OSWorX and 321 guests