Post by dogart » Sat Oct 07, 2017 1:44 am

When I look at the description wording on my featured products on home page
they don't retain any of the text formatting!
Where there is a sentence then a return to the next line it joins the words together!
Example….

If I have this text
typed out in my description
for the product it will
look like this….

If I have this texttyped out in my
descriptionfor the product it willlook like this….

Any ideas?
I use Arial font
I have a heading at 36pt set to bold
followed by a sub heading in 24pt
then bodycopy in 14pt

Cheers

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Sat Oct 07, 2017 2:02 am

The feature module by default removes html tags, so that is why your line breaks get removed.

To change that, edit catalog/controller/extension/module/featured.php and replace line 57 with the following :

Code: Select all

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

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Sat Oct 07, 2017 3:49 pm

catalog/controller/extension/module/featured.php

Is that via the Theme Editor?

But these are .twig in Theme Editor

No worries found what I need to do . . .
Filezilla hahaha

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by dogart » Sat Oct 07, 2017 4:30 pm

OK changed the .php file using text edit on my mac.
Replaced the original with the edited on via Filezilla.
When I did that I had no website just a blank page!
Luckily I saved the original, so uploaded that back and the webpage came back!!!

here is my amended line…

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

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by straightlight » Mon Oct 09, 2017 4:29 am

If using a custom theme, put your site on maintenance mode. Then, switch back to the default theme and see if the issue persists with the description text. A blank page means that the errors cannot be displayed on the screen. In order to see the errors, go to your admin error logs and see if you notice error lines from the page you were trying the provided code above. Once tested the default theme with description, disable maintenance on your store once reversed back to the custom theme.

It looks like when you tried to add the code, the $product_info would be the wrong array name but rather the: $result array name from the location to where you replaced the code.

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
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by dogart » Tue Oct 10, 2017 1:53 am

I'm using the Default Theme!

Thanks

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by dogart » Tue Oct 10, 2017 2:01 am

This what the descriptions look like on my featured items…

Attachments

Screen Shot 2017-10-10 at 2.00.19 AM.png

Screen Shot 2017-10-10 at 2.00.19 AM.png (418.78 KiB) Viewed 1640 times


New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Tue Oct 10, 2017 2:12 am

dogart wrote:
Sat Oct 07, 2017 4:30 pm
here is my amended line…

'description' => utf8_substr(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
What do you mean, is this the code you currently have?

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Tue Oct 17, 2017 12:04 am

Yes it was.

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Tue Oct 17, 2017 12:26 am

It is not the same as the line I told you to replace with.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Tue Oct 17, 2017 12:53 am

Hi,

I just cut and pasted the two to compare!
Yes I now see the diff between the two. You are right.
So that bracket makes all the diff then! hahaha
'UTF-8'),
'UTF-8')),

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by dogart » Tue Oct 17, 2017 1:00 am

??

I just checked my original and modified and both have the…
'UTF-8'))

All I did was remove strip tags as you suggested

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by dogart » Tue Oct 17, 2017 1:03 am

original…


<?php
class ControllerExtensionModuleFeatured extends Controller {
public function index($setting) {
$this->load->language('extension/module/featured');

$this->load->model('catalog/product');

$this->load->model('tool/image');

$data['products'] = array();

if (!$setting['limit']) {
$setting['limit'] = 4;
}

if (!empty($setting['product'])) {
$products = array_slice($setting['product'], 0, (int)$setting['limit']);

foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);

if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}

if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}

if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}

if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']);
} else {
$tax = false;
}

if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}

$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'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')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
}
}
}

if ($data['products']) {
return $this->load->view('extension/module/featured', $data);
}
}
}

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Tue Oct 17, 2017 1:09 am

Yes, that is the original, and the one you replaced is not the one I gave you. Replace with the one I gave you if you want it to work.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Tue Oct 17, 2017 1:41 am

OK just did that and it really F$%cked things up!!!
This is how featured boxes looked.
Have changed back to original again!

Attachments

Screen Shot 2017-10-17 at 1.37.45 AM.png

Screen Shot 2017-10-17 at 1.37.45 AM.png (1.07 MiB) Viewed 1525 times


New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Tue Oct 17, 2017 3:55 am

Yep, thats why it was there in the first place, to avoid such situations. You should consider keeping it as well, or mind the markup that goes in those descriptions.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Tue Oct 17, 2017 10:45 am

What I don't understand now is with the change to php as you suggested,
why does it then totally remove the description and then mess with the
font size/colour of the prices which are default inputs in the product data & special areas
when I create a product?

So how do I input the text for descriptions so it retains the punctuation (fullstop & returns)?

New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Tue Oct 17, 2017 8:43 pm

The changes I suggested you to make allowed markup on that description, including linebreaks. The problem is, that piece of code is also getting just a fixed part of the actual description in length, regardless of the contents, which make it likely to retrieve unclosed markup, and thus make a mess of everything else.

I guess one way would be if you count the characters in the description to know where it would be cut down, and possibly change that limit. Another option could be actual text linebreaks, but I didnt test it.

So, as you can see, it's not that easy, and recommended to be left as is.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by dogart » Fri Oct 20, 2017 1:18 pm

"Another option could be actual text linebreaks"

This what I have used.
(screenshot attached)

Attachments

Screen Shot 2017-10-20 at 1.16.57 PM.png

how it looks on the site for Featured box - Screen Shot 2017-10-20 at 1.16.57 PM.png (338.14 KiB) Viewed 1436 times

Screen Shot 2017-10-20 at 1.16.45 PM.png

how it is typed out in product description - Screen Shot 2017-10-20 at 1.16.45 PM.png (225.43 KiB) Viewed 1436 times


New member

Posts

Joined
Tue Aug 15, 2017 9:58 pm

Post by yodapt » Sun Oct 22, 2017 9:31 pm

It probably wont work with all those colors and font sizes (markup). Maybe you would be better off with a custom description just for product thumbnails.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm

Who is online

Users browsing this forum: No registered users and 14 guests