Plain text is adding HTML tags
hi
I'm trying to use the plain text for product descriptions and when i preview it; it shows fine, but when i look at my product in the catalog i notice html "<br/>" tags in the description, for every time i pressed enter (it acts like a wysiwyg) so i can not write any script because it keeps on adding unwanted tags :(
i'm running 1.3.9, php5, mySql5,
and I'm hosted by GoDaddy
Re: Plain text is adding HTML tags
You haven't said anything about how you're adding this text, but I suspect that what is happening is that Zen Cart is converting the end of line characters in your plain text into <br/> tags.
It has to really, as the XHTML used to render your plain text in a browser doesn't recognise end of line characters. The XHTML equivalent is a <br/> tag and so is appropriate to substitute, otherwise your entire product description would come out as a single line.
I'm puzzled by your comment about being unable to write script. Your product descriptions aren't the place for script. Maybe if you could expand on what you're trying to do, we can help more.
Re: Plain text is adding HTML tags
Thanks for replying
I'm entering the characters only myself no pasting or copying
Ex:
Code:
this is text
this is some more
should give you "this is text this is some more"
but it gives you
"this is text
this is some more"
and in the source i can see added <br>tags :frusty:
this should not happen in plain text mode
here is the url of the page
https://www.voucher-checks.com/compu...lips-p-86.html
The reason why I need to be able to add client-side scripts like JS or inline CSS is quite simple, i need some java script and css for a few particular pages and not for the whole site
Re: Plain text is adding HTML tags
The products_description is managed by:
Code:
$products_description = (!preg_match('/(<br|<p|<div|<dd|<li|<span)/i', $product_info->fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
So if anything is contained in the products_description then the products_description is used, as is ...
if nothing is in the products_description then the nl2br is adding the line breaks as entered ... in essence the enters you hit in plain text are doing just what you said when you hit enter ...
Re: Plain text is adding HTML tags
Nice job on the site. Very clean and professional looking. Very well suited to the products you're selling.
You have three options.
- You could remove the nl2br function call that Ajeh has highlighted and deal with any fallout elsewhere.
- You could selectively remove this function by wrapping it in an if ... else ... statement so that it isn't called for the specific products that you want to handle differently.
- You could use the Zen Cart's built-in javascript and css loading. These are documented in detail the respective readme files that come in the docs folder of a Zen Cart download. But in summary you can load css for individual products and javascript for a specific page (so you'd still need an if ... else ... statement if you needed it not to be loaded for other products).
Re: Plain text is adding HTML tags
thanks you both Ajeh and kuroi
please bare with me, lets not talk about "valid syntax" for now.
if i use white space to it should not show in the browser; however in the source code it will. line breaks are not carriage renters in plain text; they are displayed as a single "nbsp" (non breaking space).
so how can this be? both have the same descriptions
http://www.aacellphone.com/test-some-stuff-p-133.html
https://www.voucher-checks.com/compu...lips-p-86.html
Code:
non p test: top line
middle line
bottom line
<style type="text/css">
<!--
@import "https://voucher-checks.com/includes/templates/vc/css/reset_att.css";
-->
</style>
and the out put are really different
the first acts as it should and the second adds 8 break tags and screws up my code:frusty:
nl2br is not at fault, or i think so HELP!!
Re: Plain text is adding HTML tags
i checked in the database
and they both are represented exactly the same
like this
(133,1,'test some stuff','non p test: top line\r\nmiddle line\r\nbottom line\r\n\r\n<style type=\"text/css\">\r\n<!--\r\n@import \"https://voucher-checks.com/includes/templates/vc/css/reset_att.css\";\r\n\r\n-->\r\n</style>','',4)
how come they appear so differently????
Re: Plain text is adding HTML tags
One reason is that the Computer Deposit Slips is a product info page, while the 'test some stuff' is a product listing. Zencart strips HTML from the product listing description by default.
That doesn't explain why the HTML is applied to the description when entered as Plain Text, but my bone-stock test site does the same thing.
Re: Plain text is adding HTML tags
thanks
but NO its not a listing
it looks like a listing because i added an add to cart but its a product info page
the listing is
http://www.aacellphone.com/verizon-usb-cards-c-9.html
the info is
http://www.aacellphone.com/test-some-stuff-p-133.html
BTW i do not have problems in the listing, nor do i have any problems when i preview the product in the admin (before updating)
i have an ugly feeling about it cus 1.3.8 gets it fine and 1.3.9 is giving me problems , the only thing that i added to the voucher-checks site is CKeditor but its terned off and i'm working in plain text mode
if i add a <p>tag to the description like this
Quote:
non p test: top line
middle line
bottom line
<style type="text/css">
<!--
@import "https://voucher-checks.com/includes/templates/vc/css/reset_att.css";
-->
</style>
it gets it right
https://www.voucher-checks.com/test-...uff2-p-87.html
Re: Plain text is adding HTML tags
You're right, sorry.
Another 'clue' is the fact that looking at the pages using Web Developer, the product description of 'test some stuff' is inside #product_details_wrapper, and the other isn't, so it may be a template thing.