Post by antmagn » Tue Apr 08, 2025 8:50 pm

Hello everyone, I was looking for a way to make featured products look two column in mobile view and I finally found it and changed in "extension-module-featured" twig for everyone interested <div class="product-layout col-lg-3 col-md-3 col-sm-6 col-xs-6">
I think it was 12 instead of 6 , I'm not sure though ::)

I have another problem now, I get product gap in between some of my products, I mean it presents blank boxes, and I think it has to do with the title text or description, maybe too long. Is there a way to fix this, or maybe make the title text or description more restrict in character viewing to avoid that, and keep the box size of each product the same for all products. I know I might not explain it very well, I will attach screenshots to help...

Version 3.0.3.8
default theme
PHP: 7.3.13

Attachments

???
featured1.JPG
gap between featured1
???
featured2.JPG
gap between featured2
???
featured3.JPG
gap between featured3
Last edited by antmagn on Wed Apr 09, 2025 6:56 pm, edited 1 time in total.

New member

Posts

Joined
Fri Jul 23, 2021 8:38 pm

Post by by mona » Tue Apr 08, 2025 9:06 pm

catalog/view/theme/default/stylesheet/stylesheet.css - at around line 580

is this

Code: Select all

.product-thumb .caption {
    padding: 0 20px;
    min-height: 180px;
}
by changing the minimum height you fix the problem

Code: Select all

.product-thumb .caption {
    padding: 0 20px;
    min-height: 250px;
}
This will do it for everything. OC has 'optimised' code that works for its layout - if you mess with that there are consequences like this.
You will have to 'optimise' it per screen now by using @media rules with the example above of changing the min height of the thumb caption. As an example of what that means and how to implement it :
https://www.w3schools.com/cssref/atrule_media.php

To use it only in featured that will require you to explore some css rules that can indicate to css for only featured products.
Usually this is done by using css selectors. css selectors in the example above are .product-thumb and .caption - these selectors are used for all thumbs.

Alternatively (which is bad practice, but not the worst) you could add the height specific css to the twig featured template file, using the html style="min-height: 250px" system. This unfortunately will not be available to use @media rules.

As another possible thought for a non coder - if you change the sort ordering of the featured to use the odd number as the offending thumb you can "hide" the issue that way.

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 johnp » Wed Apr 09, 2025 6:27 am

by mona wrote:
Tue Apr 08, 2025 9:06 pm
catalog/view/theme/default/stylesheet/stylesheet.css - at around line 580

is this

Code: Select all

.product-thumb .caption {
    padding: 0 20px;
    min-height: 180px;
}
by changing the minimum height you fix the problem

Code: Select all

.product-thumb .caption {
    padding: 0 20px;
    min-height: 250px;
}
This will do it for everything. OC has 'optimised' code that works for its layout - if you mess with that there are consequences like this.
You will have to 'optimise' it per screen now by using @media rules with the example above of changing the min height of the thumb caption. As an example of what that means and how to implement it :
https://www.w3schools.com/cssref/atrule_media.php

To use it only in featured that will require you to explore some css rules that can indicate to css for only featured products.
Usually this is done by using css selectors. css selectors in the example above are .product-thumb and .caption - these selectors are used for all thumbs.

Alternatively (which is bad practice, but not the worst) you could add the height specific css to the twig featured template file, using the html style="min-height: 250px" system. This unfortunately will not be available to use @media rules.

As another possible thought for a non coder - if you change the sort ordering of the featured to use the odd number as the offending thumb you can "hide" the issue that way.
This may be of use:

https://www.bootstrap-live-customizer.com

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by antmagn » Wed Apr 09, 2025 1:48 pm

Thank you but unfortunately I still get those gaps in mobile view but I can see the change in desktop view, the boxes are taller...the code is inside

Code: Select all

@media (min-width: 767px) {
if that helps....Maybe it's possible to use meta description instead of actual description in those thumbs, will this help? I think it would look better without looking corrupted also.
As another possible thought for a non coder - if you change the sort ordering of the featured to use the odd number as the offending thumb you can "hide" the issue that way.
What do you mean?

Attachments

Capture4.JPG

gaps - Capture4.JPG (20.56 KiB) Viewed 630 times


New member

Posts

Joined
Fri Jul 23, 2021 8:38 pm

Post by by mona » Wed Apr 09, 2025 6:05 pm

antmagn wrote:
Wed Apr 09, 2025 1:48 pm
Thank you but unfortunately I still get those gaps in mobile view
You increase the height until they dont.


antmagn wrote:
Wed Apr 09, 2025 1:48 pm
... is it possible to use meta description instead on actual description in those thumbs
In catalog controller/extension/module/featured.php
find

Code: Select all

'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
change to

Code: Select all

'description' =>$product_info['meta_description'],

antmagn wrote:
Wed Apr 09, 2025 1:48 pm
will it help?
Depends on your meta description length


antmagn wrote:
Wed Apr 09, 2025 1:48 pm
What do you mean?
Add them in a different order.


Remember to refresh your cache. Please be aware that questions to modify Opencart fall outside of free support and that modifications should be using modifications.

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 by mona » Wed Apr 09, 2025 6:09 pm

Code: Select all

@media (min-width: 767px) {
That says if the media is at least (a minimum of) 767px width

Code: Select all

@media (max-width: 768px) {
That says if the media is no more than (a maximum of) 768px width

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 antmagn » Wed Apr 09, 2025 6:23 pm

Thank you, I used meta_description instead and now they look better and not corrupted, still if the meta is long, I get the same problem but I can fix this easier since meta should not be too long, I know this has to do with another topic which is not oc related.
Can I implement this change to related products also?

New member

Posts

Joined
Fri Jul 23, 2021 8:38 pm

Post by antmagn » Wed Apr 09, 2025 6:26 pm

by mona wrote:
Wed Apr 09, 2025 6:09 pm

Code: Select all

@media (min-width: 767px) {
That says if the media is at least (a minimum of) 767px width

Code: Select all

@media (max-width: 768px) {
That says if the media is no more than (a maximum of) 768px width
I know that I just wondered if I put the code out of this condition will make any difference.... but still did not work, meta_description solution looks much better

New member

Posts

Joined
Fri Jul 23, 2021 8:38 pm

Post by by mona » Wed Apr 09, 2025 6:43 pm

antmagn wrote:
Wed Apr 09, 2025 6:23 pm
Thank you
You are welcome


antmagn wrote:
Wed Apr 09, 2025 6:23 pm
if the meta is long, I get the same problem
Yes because it is bootstrap and that straps it in like bootlaces - there are so many screen sizes that the 'correct' way is far more complicated to fix and requires a significant amount of personalised effort using media queries that you will have to put in the effort yourself or pay a developer to do for you. It is quicker for a developer but it is work. I have provided you with the way to do it and an example - the actual calculation of heights / description length (or meta length) and media rules to make it work on each and every device is specific.


antmagn wrote:
Wed Apr 09, 2025 6:23 pm
Can I implement this change to related products also?
Related is in catalog/controller/product/product.php under getProductRelated.



You can also try to play with css line-clamping

Code: Select all

.product-thumb .caption {
  -webkit-line-clamp: 3;
  overflow: hidden;
}

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 antmagn » Wed Apr 09, 2025 6:56 pm

by mona wrote:
Wed Apr 09, 2025 6:43 pm
antmagn wrote:
Wed Apr 09, 2025 6:23 pm
Thank you
You are welcome


antmagn wrote:
Wed Apr 09, 2025 6:23 pm
if the meta is long, I get the same problem
Yes because it is bootstrap and that straps it in like bootlaces - there are so many screen sizes that the 'correct' way is far more complicated to fix and requires a significant amount of personalised effort using media queries that you will have to put in the effort yourself or pay a developer to do for you. It is quicker for a developer but it is work. I have provided you with the way to do it and an example - the actual calculation of heights / description length (or meta length) and media rules to make it work on each and every device is specific.


antmagn wrote:
Wed Apr 09, 2025 6:23 pm
Can I implement this change to related products also?
Related is in catalog/controller/product/product.php under getProductRelated.



You can also try to play with css line-clamping

Code: Select all

.product-thumb .caption {
  -webkit-line-clamp: 3;
  overflow: hidden;
}
Thank you very much, you were very helpful! I will mark as solved

New member

Posts

Joined
Fri Jul 23, 2021 8:38 pm

Post by by mona » Wed Apr 09, 2025 7:26 pm

antmagn wrote:
Wed Apr 09, 2025 6:56 pm
Thank you very much, you were very helpful!
You are welcome

antmagn wrote:
Wed Apr 09, 2025 6:56 pm
I will mark as solved
Thank 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
Who is online

Users browsing this forum: Majestic-12 [Bot] and 119 guests