Post by CJC » Thu Feb 04, 2021 10:26 pm

I'm have the Featured Products section enabled on our homepage. When the product description for each item is rendered it displays as one long run-on sentence. Any <p> or <br> tags in the original product description are ignored.

This is how the product description is defined: Image

And this is how it renders:
Image

Any ideas why this happens? Also, the 2 periods at the end are not part of the description either. Where are those coming from?
Last edited by CJC on Sat Feb 06, 2021 1:56 am, edited 1 time in total.

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by mikeinterserv » Thu Feb 04, 2021 10:30 pm

Well its the quote marks

Do this if you must have them

Code: Select all

4" x 4"
Enter the quotes directly in edit mode not code view then it should work
Or not
I have tried a few methods without success either I will find a way or someone will come along and tell you and laugh at me :-)

Attachments

Clipboard07.jpg

Clipboard07.jpg (3.65 KiB) Viewed 1316 times

Last edited by mikeinterserv on Thu Feb 04, 2021 11:00 pm, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by CJC » Thu Feb 04, 2021 10:49 pm

Nope, not the quote marks at all. I can remove them completely and it renders the same way. Also, doesn't explain the extra periods at the end.
mikeinterserv wrote:
Thu Feb 04, 2021 10:30 pm
Well its the quote marks

Do this if you must have them

Code: Select all

4" x 4"
Enter the quotes directly in edit mode not code view then it should work

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by pprmkr » Thu Feb 04, 2021 11:05 pm

CJC wrote:
Thu Feb 04, 2021 10:26 pm
Any ideas why this happens? Also, the 2 periods at the end are not part of the description either. Where are those coming from?

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')) . '..',
Code can be found in category, search, special and manufacturer and in modules featured, special, latest and bestseller ...

In Extensions - Themes : Your theme the product description length can be set.

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by mikeinterserv » Thu Feb 04, 2021 11:20 pm

CJC wrote:
Thu Feb 04, 2021 10:49 pm
Nope, not the quote marks at all. I can remove them completely and it renders the same way. Also, doesn't explain the extra periods at the end.
mikeinterserv wrote:
Thu Feb 04, 2021 10:30 pm
Well its the quote marks

Do this if you must have them

Code: Select all

4" x 4"
Enter the quotes directly in edit mode not code view then it should work
The periods at the end are the continuation marks for short text.
The post above shows you where they are in the code if you want to remove them

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by mikeinterserv » Thu Feb 04, 2021 11:30 pm

The short description for featured and category is handled differently to the product page
There is not much of a workaround without editing some code by the look of it and yes it creates just a flow of text to the character limit stripping anything in its path :-)

If you are happy to edit the code you can do this
BACKUP the ORIGINAL FILE FIRST

catalog/controller/extension/module/featured.php
If you have extension/mod that uses featured the page will be in system/storage/modification/yourmod
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')) . '..',
Replace with

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'),
Now html tags will not be ignored and they will be correctly decoded by html_entity_decode
This will also eliminate the periods

pprmkr made a good post also and to remind you you can also edit the length of the short description in the theme settings.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by CJC » Fri Feb 05, 2021 4:08 am

Could you explain this a bit more?
If you have extension/mod that uses featured the page will be in system/storage/modification/yourmod

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by mikeinterserv » Fri Feb 05, 2021 4:16 am

Yes certainly
If you have an installed extension that may use the featured page for example, an out of stock ribbon and add cart disable the mod will place the modified files in a directory structure in system/storage/modification/yourmodification/catalog/controller/extension/featured.php
or it may just be
system/storage/modification/catalog/controller/extension/featured.php
it will be obvious to you when you find it
This is how OC uses mods without affecting core files. If you need to edit featured of a mod then the system path you need to test.
If no mods then the standard path to the original file is what you need. If you edit the original and LATER add MOD you can get a bit confused as to whats going on. Hope that helps

Just to note: This is not something to do unless you really need to, but if you really need to this is the solution to do it. Just make sure you backup your original file and you can reverse it in an instant if you get something wrong. It will do no other harm in any way to anything else.
Last edited by mikeinterserv on Fri Feb 05, 2021 5:34 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Feb 05, 2021 4:23 am

When you install and extension it makes edits (not always but in this explanation).
These edits are say - on this file change the word “yes” to “no”
This edit then becomes the “new” file
this file is stored in your modification folder (where that is is where you put it and further explanation may require your OC version)


What this means is that everytime you press the refresh button in the modifications page - it re-creates these files - and these are the ones that show on your front-end

However - if you change the modifed file it will only edit your front-end for as long as your modifications are not refreshed

So the bottom line is you do not need to touch this file - you need the actual file
- this file will only be of use if the code you are changing has already been changed - so it in effect is running before you walk
usually resulting in falling over -

so ignore all of that and just try the edit on the correct file as suggested

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by CJC » Fri Feb 05, 2021 5:17 am

Ok, got it. I don't have anything modifying the featured module yet, so that's why I don't see anything there.
Thank You.
mikeinterserv wrote:
Fri Feb 05, 2021 4:16 am
Yes certainly
If you have an installed extension that may use the featured page for example, an out of stock ribbon and add cart disable the mod will place the modified files in a directory structure in system/storage/modification/yourmodification/catalog/controller/extension/featured.php
or it may just be
system/storage/modification/catalog/controller/extension/featured.php
it will be obvious to you when you find it
This is how OC uses mods without affecting core files. If you need to edit featured of a mod then the system path you need.
If no mods then the standard path to the original file is what you need. If you edit the original and LATER add MOD you can get a bit confused as to whats going on. Hope that helps

Just to note: This is not something to do unless you really need to, but if you really need to this is the solution to do it. Just make sure you backup your original file and you can reverse it in an instant if you get something wrong. It will do no other harm in any way to anything else.

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by CJC » Fri Feb 05, 2021 5:21 am

I understand now. What's interesting is that I have a modification I installed to change something in a language file, but that modified language file doesn't show up in the system/storage/modification directory.
by mona wrote:
Fri Feb 05, 2021 4:23 am
When you install and extension it makes edits (not always but in this explanation).
These edits are say - on this file change the word “yes” to “no”
This edit then becomes the “new” file
this file is stored in your modification folder (where that is is where you put it and further explanation may require your OC version)


What this means is that everytime you press the refresh button in the modifications page - it re-creates these files - and these are the ones that show on your front-end

However - if you change the modifed file it will only edit your front-end for as long as your modifications are not refreshed

So the bottom line is you do not need to touch this file - you need the actual file
- this file will only be of use if the code you are changing has already been changed - so it in effect is running before you walk
usually resulting in falling over -

so ignore all of that and just try the edit on the correct file as suggested

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by by mona » Fri Feb 05, 2021 5:31 am

new topic - new thread please -
Please state your OC version
Post the OCMOD
Post the OCMOD log TAB

Then we can help you with that.

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Feb 05, 2021 5:33 am

by mona wrote:
Fri Feb 05, 2021 4:23 am
What this means is that everytime you press the refresh button in the modifications page - it re-creates these files - and these are the ones that show on your front-end
Which is exactly how you test it first without damage - one quick refresh and your back to where you were
Then you can modify the file you need

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Feb 05, 2021 5:42 am

You should not be using users to test your theories ..
developers sometimes test that way yes - the user is not a developer - simple problems - simple solutions - not baffle with science - it just causes confusion -

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Feb 05, 2021 5:46 am

mikeinterserv wrote:
Fri Feb 05, 2021 4:16 am
Just to note: This is not something to do unless you really need to, but if you really need to this is the solution to do it. Just make sure you backup your original file and you can reverse it in an instant if you get something wrong. It will do no other harm in any way to anything else.
Well Mona finally we agree on something

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Feb 05, 2021 6:03 am

So just to clarify this post to make it of use both to the user (apologies) and the forum users generally

The issue is that the featured module removes html tagging - which is things like <p> and <br/>
This is done in this file
catalog/controller/extension/module/featured.php
on this line

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')) . '..',
and if it is changed to

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'),
you will notice that instead of the code strip_tags it changes to the code html_entity_decode

and the two dots at the end is because the length of the description is set in admin

Code: Select all

'theme_' . $this->config->get('config_theme') . '_product_description_length'
Please mark this topic as solved by adding [SOLVED] to the title if it helps - so any other users in the future may be able to benefit

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Feb 05, 2021 6:11 am

That's ^^^^ about the perfect summary :-)

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by CJC » Sat Feb 06, 2021 12:19 am

I will create a new thread for that.
Thank You.
by mona wrote:
Fri Feb 05, 2021 5:31 am
new topic - new thread please -
Please state your OC version
Post the OCMOD
Post the OCMOD log TAB

Then we can help you with that.

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am

Post by straightlight » Sat Feb 06, 2021 12:52 am

by mona wrote:
Fri Feb 05, 2021 6:03 am
So just to clarify this post to make it of use both to the user (apologies) and the forum users generally

The issue is that the featured module removes html tagging - which is things like <p> and <br/>
This is done in this file
catalog/controller/extension/module/featured.php
on this line

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')) . '..',
and if it is changed to

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'),
you will notice that instead of the code strip_tags it changes to the code html_entity_decode

and the two dots at the end is because the length of the description is set in admin

Code: Select all

'theme_' . $this->config->get('config_theme') . '_product_description_length'
Please mark this topic as solved by adding [SOLVED] to the title if it helps - so any other users in the future may be able to benefit
Take note this approach has been modified on the master branch for future reference, however. Prefixes with, either, the default theme and custom themes are no longer used this way.

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 CJC » Sat Feb 06, 2021 1:04 am

I just tried creating an ocmod to do this and it ends up causing a 500 error on the front end. Here's the ocmod code - does anything look off?

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Featured Module Fix</name>
<code>Featured module</code>
    <version>1.4</version>
    <author>C2 It</author>
    <link>http://www.c2-it.com</link>
    <file path="catalog/controller/extension/module/featured.php">
        <operation>
            <search><![CDATA['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')) . '..',]]></search>
            <add position="replace"><![CDATA['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'),]]></add>
        </operation>
    </file>  
</modification>
by mona wrote:
Fri Feb 05, 2021 6:03 am
So just to clarify this post to make it of use both to the user (apologies) and the forum users generally

The issue is that the featured module removes html tagging - which is things like <p> and <br/>
This is done in this file
catalog/controller/extension/module/featured.php
on this line

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')) . '..',
and if it is changed to

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'),
you will notice that instead of the code strip_tags it changes to the code html_entity_decode

and the two dots at the end is because the length of the description is set in admin

Code: Select all

'theme_' . $this->config->get('config_theme') . '_product_description_length'
Please mark this topic as solved by adding [SOLVED] to the title if it helps - so any other users in the future may be able to benefit

CJC
Active Member

Posts

Joined
Wed Jun 03, 2020 5:51 am
Who is online

Users browsing this forum: No registered users and 30 guests