Post by Gobbo » Mon Jan 20, 2025 9:45 am

Hi,

How can we reduce the displayed product title to one line on the home page?

This is to align all of our 'Add To Cart' buttons.

Thanks in advance ;)

Using opencart 3.0.3.2 - PHP 7.4 - Standard Template - Add to Cart Enable Disable Out of Stock Product 3.x - Export/Import Tool (V3.22) for OpenCart 3.x - Footer Social Media Link( 3.x ) v1.0


Active Member

Posts

Joined
Tue Jun 22, 2010 12:38 am

Post by softmonke » Mon Jan 20, 2025 10:44 am

Gobbo wrote:
Mon Jan 20, 2025 9:45 am
Hi,

How can we reduce the displayed product title to one line on the home page?

This is to align all of our 'Add To Cart' buttons.

Thanks in advance ;)
You can try adding the following CSS style to the <h4> tag (assuming you are using the default OpenCart theme) of your product title:

Code: Select all

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
This will force all titles that exceed a single line to be truncated and end with an ellipsis.

If you don't want to truncate your product title but still want to keep your cart buttons aligned, you can try increasing the min-height of ".product-thumb .caption" in stylesheet.css (again, assuming your are using the default OpenCart theme).

If you are using another theme, the above still applies but you will need to target the correct HTML elements.

Check out our ever-growing list of extensions for OpenCart here.
Some useful extensions for a better admin experience: Image File Manager ProDrag & Drop Sort Order

Reach out to us at hello@softmonke.com for your OpenCart web development needs or feedback for our extensions.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by paulfeakins » Mon Jan 20, 2025 7:04 pm

Gobbo wrote:
Mon Jan 20, 2025 9:45 am
How can we reduce the displayed product title to one line on the home page?
You can see how it appears on our themes: https://www.antropy.co.uk/opencart-serv ... me-builds/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Gobbo » Sun Feb 16, 2025 5:40 am

softmonke wrote:
Mon Jan 20, 2025 10:44 am
Gobbo wrote:
Mon Jan 20, 2025 9:45 am
Hi,

How can we reduce the displayed product title to one line on the home page?

This is to align all of our 'Add To Cart' buttons.

Thanks in advance ;)
You can try adding the following CSS style to the <h4> tag (assuming you are using the default OpenCart theme) of your product title:

Code: Select all

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
This will force all titles that exceed a single line to be truncated and end with an ellipsis.

If you don't want to truncate your product title but still want to keep your cart buttons aligned, you can try increasing the min-height of ".product-thumb .caption" in stylesheet.css (again, assuming your are using the default OpenCart theme).

If you are using another theme, the above still applies but you will need to target the correct HTML elements.
Entered this on the CSS, but it doesn't work.

Code: Select all

 .product-thumb h4 {
	font-weight: bold;
	white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

Using opencart 3.0.3.2 - PHP 7.4 - Standard Template - Add to Cart Enable Disable Out of Stock Product 3.x - Export/Import Tool (V3.22) for OpenCart 3.x - Footer Social Media Link( 3.x ) v1.0


Active Member

Posts

Joined
Tue Jun 22, 2010 12:38 am

Post by nonnedelectari » Sun Feb 16, 2025 12:56 pm

css is browser cached, you cleared that right?

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by Gobbo » Mon Feb 17, 2025 1:18 am

Yes, we cleared the history.

Using opencart 3.0.3.2 - PHP 7.4 - Standard Template - Add to Cart Enable Disable Out of Stock Product 3.x - Export/Import Tool (V3.22) for OpenCart 3.x - Footer Social Media Link( 3.x ) v1.0


Active Member

Posts

Joined
Tue Jun 22, 2010 12:38 am

Post by by mona » Mon Feb 17, 2025 11:01 am

The code works.
You either have a theme that edits the css selector or you have some caching that prevents it updating in real time.

You could also use the code from the product category controller and follow the same principle as the description.

Code: Select all

'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
This uses the admin config but it can be replaced that with a number.

A third option is to increase the height of the product thumb, this would also align all the add to cart buttons

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 knowband.plugins » Thu Feb 27, 2025 4:43 pm

by mona wrote:
Mon Feb 17, 2025 11:01 am
You could also use the code from the product category controller and follow the same principle as the description.

Code: Select all

'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
This uses the admin config but it can be replaced that with a number.
@by mona, It doesn't seem a good practice to make the changes with static values, as the same might not work with different screen sizes.

Regards,
Knowband Team

Opencart Plugins: Knowband Store
Email: support@knowband.com


User avatar
Active Member

Posts

Joined
Thu Aug 04, 2016 2:56 pm

Post by JNeuhoff » Thu Feb 27, 2025 7:04 pm

Using opencart 3.0.3.2 - PHP 7.4 - Standard Template - Add to Cart Enable Disable Out of Stock Product 3.x - Export/Import Tool (V3.22) for OpenCart 3.x - Footer Social Media Link( 3.x ) v1.0
BTW.: You should use V4.17.x of the Export/Import tool, Version 3.22 is quite old.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Thu Feb 27, 2025 10:33 pm

@knowband.plugins,
It doesn't seem a good practice to make the changes with static values, as the same might not work with different screen sizes.
Indeed it might not work and then again it might

The description is already static and the thumbs are coded for screen sizes (with height issues), but most importantly the css code is not working for them despite it being correct. It is an alternative. Best practice is probably the wrong word, maybe not the best choice in all circumstances, but quite possibly the best choice in another circumstance.

I find the thumb height issue the most annoying, the user finds the title, you find the filling the screen space on all devices. The world is a wonderful box of liquorice allsorts.

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 jrr » Fri Mar 07, 2025 8:43 am

paulfeakins wrote:
Mon Jan 20, 2025 7:04 pm
Gobbo wrote:
Mon Jan 20, 2025 9:45 am
How can we reduce the displayed product title to one line on the home page?
You can see how it appears on our themes: https://www.antropy.co.uk/opencart-serv ... me-builds/
"Oops!
Looks like we've moved the page you were after!"

John :-#(#

jrr
Active Member

Posts

Joined
Mon Nov 20, 2017 1:48 pm

Post by paulfeakins » Fri Mar 07, 2025 11:43 pm

jrr wrote:
Fri Mar 07, 2025 8:43 am
paulfeakins wrote:
Mon Jan 20, 2025 7:04 pm
Gobbo wrote:
Mon Jan 20, 2025 9:45 am
How can we reduce the displayed product title to one line on the home page?
You can see how it appears on our themes: https://www.antropy.co.uk/opencart-serv ... me-builds/
"Oops!
Looks like we've moved the page you were after!"

John :-#(#
That's for spotting that one, I've raised it with the team.

In the meantime you can see our themes here:
https://www.opencart.com/index.php?rout ... er=antropy

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: pprmkr, sidclel and 73 guests