Print Page | Close Window

Custom Fields text format

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=858
Printed Date: 21-April-2025 at 12:57am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Custom Fields text format
Posted By: mattprice
Subject: Custom Fields text format
Date Posted: 03-June-2007 at 3:29am

Hello,

Sorry, only my second post and I am asking questions rather than helping to answer them (I will redeem myself as I get to grips with this program)

I have a problem with the display of text in a custom field. I am using a Text Area custom field to capture a customers wording details.  The carriage returns that the customer enters are important to the layout but are not retained when the text is subsquently being pulled from the database.

Eg :-

When the customer enters the text :-

Mr & Mrs S Smith
request the pleasure of the company of

......................................
to celebrate the marriage of their daughter

Claire
with
Thomas

it translates to the following truncated text when pulled from the database in the subsequent viewbasket and checkout screens and in the backend after order completion

Mr & Mrs S Smith request the pleasure of the company of ...................................... to celebrate the marriage of their daughter Claire with Thomas 

Does anybody know how to retain these line breaks when the custom field is redisplayed.

Many Thanks

Matt




Replies:
Posted By: mattprice
Date Posted: 03-June-2007 at 4:38am

I havent solved my problem but I have just realised that the order confirmation sent to a customer does have these line breaks in place so that the text is formatted correctly.  Also, when I look at the order in the back the text is not formatted correctly at first but if I click on the edit link to edit the custom field as an administrator and save it again (without actually making any changes) the text miraculously reformats itself as it was originally entered by the customer.  I guess the line breaks are correctly being held in the database.

Therefore, my only real issue is how the text is being formatted in the view basket and checkout screens which would confuse a customer in thinking that their text has been all wrapped together when in actual fact it has been captured correctly.

If anyone has any ideas I would be most grateful.

Many Thanks

Matt



Posted By: thedeacon
Date Posted: 03-June-2007 at 5:57am

Hi Matt,

Have them indicate line breaks with "<br>" (without the quotes)

and you should be all good :)



Posted By: thedeacon
Date Posted: 03-June-2007 at 6:01am
Whoops!  I was looking at the wrong thing there.  Give me a moment and ignore my last post.


Posted By: thedeacon
Date Posted: 03-June-2007 at 6:13am

Hi again,

I'll have another look at it a bit later.  What happens is that all formatting and HTML code is removed from the text on the shopping cart summary. 

My guess as to why follows:

1) To prevent exploits.  If all code and formatting weren't removed, an unscrupulous individual could technically throw in a bunch of code in that text field to crash your server or a script that would download the entire contents of your database and then delete it off your server. 

2) To keep the page's appearance from becoming altered.  If the HTML code and formatting were left in, I could add in a tag that says something like

<font style="font-size: 3000px"> and without the corresponding </font> tag to close it out, the rest of your page would be in humungous text.

Technically, the page could be altered to allow certain tags and even force them to close out the tags at the end of the input field, but there's a bit of work involved in that.

You could always put in something like "Unformatted preview text - text will display properly in your confirmation email"



Posted By: mattprice
Date Posted: 03-June-2007 at 8:06am

I have had a dig a bit further because I am curious as to why if I edit the custom field text on an order in admin I can restore the correct html display with the <br> returns in place simply by clicking on the edit link from within an order and updating the field entry without changing any text or formatting.

This edit custom field link when viewing an order in the backend pulls up a customInput_popup.asp file that has a routine to '// Repair HTML for the Line Return.  This routine seems to replace &lt;BR&gt; with <BR> in a number of places.

My problem now is figuring out how to get this "Html repair" when the custom field is displayed on the viewcart.asp screen.  :-(

 



Posted By: thedeacon
Date Posted: 04-June-2007 at 12:24am

I was a bit engaged today, but I took a quick look and it's not jumping out at me.  I would have figured there'd be a "ClearHTMLTags" command and there's a chance there is somewhere, just not on the viewcart.asp page.

At the beginning of viewcart.asp, it includes a number of files

(<!--#include file="../includes/settings.asp"-->
<!--#include file="../includes/storeconstants.asp"-->
<!--#include file="../includes/emailsettings.asp"-->
<!--#include file="../includes/languages.asp"-->
<!--#include file="../includes/languages_ship.asp"-->
<!--#include file="../includes/bto_language.asp"-->
<!--#include file="../includes/productcartinc.asp"-->
<!--#include file="../includes/currencyformatinc.asp"-->
<!--#include file="../includes/shipFromSettings.asp"-->
<!--#include file="../includes/productcartFolder.asp"-->
<!--#include file="../includes/opendb.asp"-->
<!--#INCLUDE FILE="../includes/stringfunctions.asp"-->
<!--#include file="../includes/adovbs.inc"-->
<!--#include FILE="../includes/ErrorHandler.asp"-->
<!--#include FILE="../includes/pcProductOptionsCode.asp"--> 
<!--#include file="header.asp"-->
<!--#include file="inc_PrdCatTip.asp"-->
<!--#include file="pcCheckPricingCats.asp"-->)

So the command is most likely somewhere in one of those files and can be edited to allow certain html tags.  I keep raising mental red flags though whenever I think about allowing arbitrary code in an input text field though :p

I'm sure I can find the code, but time is a bit of an issue at the moment.  I'll check back in though!



Posted By: mattprice
Date Posted: 04-June-2007 at 1:56am

No problem Richard,

I really appreciate your help.

After reading the following short extract on texareas at http://www.learnasp.com/freebook/asp/formtextarea.aspx - http://www.learnasp.com/freebook/asp/formtextarea.aspx  I am convinced it is something to do with how textareas are handled in ASP because there is a tip at the bottom of the page about retaining hard-returns that a user types.

It gives the following eg.

comm=replace(var,vbcrlf,"<br>")

I think (but am probably completely wrong because I dont know much about ASP) that I need to incorporate this replacing of vbcrlf stored in the database with <br> at output and I reckon I need to do it in viewcart.asp here :-

      <!-- START 5th Row - Custom Input Fields -->
      <% 'if there are custom input fields, show them here
      if trim(pcCartArray(f,21))<>"" then %>
       <tr>
        <td>&a mp;nbsp;</td>
        <td colspan="3">
         <p& gt;<% response.write replace(pcCartArray(f,21),"''","'") %></p>
        </td>
        <td>&a mp;nbsp;</td>
        <td>&a mp;nbsp;</td>
       </tr>
      <% End if %>

I have messed around here for ages but cannot seem to crack it.  I'll keep on trying



Posted By: thedeacon
Date Posted: 04-June-2007 at 2:32am
You're absolutely on the right track though :)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net