Post by dangchung » Sat Jul 06, 2019 10:39 am

Hi,
My website has a problem with the length of product name in category page. The product title always displays maximum in 2 lines (cannot show in 3 lines or more) though I tried to edit the code in catalog/controller/product/category.php as below:

Code: Select all

$result['name'] = strlen($result['name']) > 50 ? substr($result['name'],0,50) . '...' : $result['name'];		
				$data['products'][] = array(
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
					'name'    	 => utf8_substr($result['name'],0,50),
					'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')) . '..',
					'price'       => $price,
					'text_percent'  => $text_percent,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
I also tried to find if there is any css that limit the line but no result.
Image
Please help me how to show the product title fully.
Thanks

Newbie

Posts

Joined
Wed Jul 04, 2018 11:31 am

Post by xxvirusxx » Sun Jul 07, 2019 1:36 am

Change this

Code: Select all

'name'    	 => utf8_substr($result['name'],0,50),
to this

Code: Select all

'name'     	 => $result['name'],

Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - RO

Post by straightlight » Sun Jul 07, 2019 2:11 am

Also, this line needs to be edited:

Code: Select all

$result['name'] = strlen($result['name']) > 50 ? substr($result['name'],0,50) . '...' : $result['name'];

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dangchung » Sun Jul 07, 2019 11:54 am

Hi,
Thanks for your helps, but the problem is still occurred. Here is my code after changes:

Code: Select all

				$data['products'][] = array(
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
					'name'     	 => $result['name'],
					'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')) . '..',
					'price'       => $price,
					'text_percent'  => $text_percent,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
The product name in category page is still display maximum in 2 lines, it cannot be shown more.

Newbie

Posts

Joined
Wed Jul 04, 2018 11:31 am

Post by xxvirusxx » Sun Jul 07, 2019 5:24 pm

- Clear vqmod cache (if you have vqmod installed)
- Refresh Ocmod modifications
- Clear Theme Cache and SASS Cache

Active Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - RO

Post by kestas » Sun Jul 07, 2019 7:14 pm

straightlight wrote:
Sun Jul 07, 2019 2:11 am
Also, this line needs to be edited:

Code: Select all

$result['name'] = strlen($result['name']) > 50 ? substr($result['name'],0,50) . '...' : $result['name'];
you should use utf8_substr instead substr in case if you use some different language to support all utf8 fonts.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by dangchung » Sun Jul 07, 2019 10:37 pm

xxvirusxx wrote:
Sun Jul 07, 2019 5:24 pm
- Clear vqmod cache (if you have vqmod installed)
- Refresh Ocmod modifications
- Clear Theme Cache and SASS Cache
Hi,
The problem is still occured. I don't use vqmod, and I refreshed ocmod modification + theme cache + sass cache in admin panel.
Last edited by dangchung on Sun Jul 07, 2019 11:27 pm, edited 1 time in total.

Newbie

Posts

Joined
Wed Jul 04, 2018 11:31 am

Post by kestas » Sun Jul 07, 2019 10:43 pm

admin dashboard blue gear icon in the right upper corner.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by straightlight » Mon Jul 08, 2019 12:06 am

If the issue still persists after following the FAQ: viewtopic.php?f=176&t=200804#p718325 , then the problem might be related to one of these twos: viewtopic.php?f=176&t=200804#p717782 and viewtopic.php?f=176&t=200804#p731004 (or both).

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dangchung » Wed Sep 11, 2019 8:33 pm

Thanks so much, it worked.

Newbie

Posts

Joined
Wed Jul 04, 2018 11:31 am
Who is online

Users browsing this forum: Baidu [Spider], paulfeakins and 11 guests