Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Replace
derekjohnston
I have developed a datacapture.cfg which consists only of a text area.
The contents of this textarea will be placed in a table with an outline border.
In the template I check if the text area is not empty and I display the table and contents. If not I display nothing.
However if a user accidently leaves a space in the html => the table is displayed with nothing in it.
So I wrote some perl script to replace all the and check if the content was empty.
However the seems to a reserved word in homesite and the script does not work in teamsite but will work in a activeperl .
Perl scrip is:
<iw_perl>
$htmlContent = iwpt_dcr_value('dcr.CustomerAlert.html');
$remove = ' ';
$replace = "";
$htmlContent =~ s/$remove/$replace/g;
</iw_perl>
has anyone any suggestions
Find more posts tagged with
Comments
JonathonG
My guess is that the xml parser that runs on your presentation template is gobbling up the entity. To verify this, try something like:
$remove = '&' . 'nbsp;';
$htmlContent =~ s/$remove//g;
If you get an error from this, then you probably need to make your iw_pt tag at the top of your presentation template self-closing, e.g. <iw_pt/>
If none of this helps, try posting your entire pt and maybe someone here can figure out what's going on.
Jonathon
Interwoven Developer
Allstate, Inc.
derekjohnston
<iw_if expr="defined iwpt_get_flag_param('-iw_pt-preview')">
<iw_then>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Customer Alert Preview</title>
<link rel="STYLESHEET" type="text/css" href="/common/stylesheet/servicing.css">
</head>
<body >
<table width="555" border="0" cellspacing="0" cellpadding="0"><tr><td>
</iw_then>
</iw_if>
<iw_perl>
$htmlContent = iwpt_dcr_value('dcr.CustomerAlert.html');
$remove = '&' . 'nbsp;';
$htmlContent =~ s/$remove//g;
</iw_perl>
<iw_if expn="{iw_value name='$htmlContent'/} ne ''">
<iw_then>
<table width="555" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10" valign="top"><img src="/common/images/layout/cnr-gry_top-lft.gif" alt="" width="10" height="10"></td>
<td class="tableBorderTop" width="100%" colspan="2"><img src="/common/images/spacer.gif" alt="" width="1" height="1"></td>
<td height="10" valign="top"><img src="/common/images/layout/cnr-gry_top-rht.gif" alt="" width="10" height="10"></td>
</tr>
<tr>
<td class="tableBorderLeft" align="left"><img src="/common/images/spacer.gif" alt="" width="1" height="90"></td>
<td width="100%" colspan="2"><iw_value name="dcr.CustomerAlert.html" /></td>
<td class="tableBorderRight" align="right"><img src="/common/images/spacer.gif" alt="" width="1" height="90"></td>
</tr>
<tr>
<td><img src="/common/images/layout/cnr-gry_bot-lft.gif" alt="" width="10" height="10"></td>
<td class="tableBorderBottom" colspan="2"><img src="/common/images/spacer.gif" alt="" width="1" height="1"></td>
<td><img src="/common/images/layout/cnr-gry_bot-rht.gif" alt="" width="10" height="10"></td>
</tr>
</table>
</iw_then>
</iw_if>
<iw_if expr="defined iwpt_get_flag_param('-iw_pt-preview')">
<iw_then>
</td></tr></table>
</iw_then>
</iw_if>
tried what you said, but it did not work - where does the iw_pt tag sit?
I am new to teamsite so excuse the stupid questions
jbonifaci
You place the <iw_pt /> tag at the top of your tpl so you don't have to worry about well formatted xml in your document. If you still can't figure it out, please post your tpl as an attachment, not as text in your post and someone can help point you in the right direction I'm sure.
~Jeff
derekjohnston
Hi,
Have attached the tpl.
any help would be much appreciated.
thanks
Derek
jbonifaci
What exactly is happening that you don't want to happen? Have you tried logging or printing out the contents of $htmlContent? Also, rather than manipulating $htmlContent just to check if it is all spaces, have you considered using a regular expression:
<iw_if expn="{iw_value name='dcr.CustomerAlert.html'/} !~ m/^(?: |\s)*$/">
This is untested, but I would think something like this would be better if your only purpose is to check if the item is only whitespace.
~Jeff
derekjohnston
Hi,
If the content is purely spaces than I wish to display nothing. As you say i just want to check if it contains only spaces. I will try the reg exp route as you suggested and get the one you supplied working.
thanks for all your help
Derek
derekjohnston
HI,
the regex you provide works fine in active perl but when I insert it into my tpl i get an xml parser error. eg XML parse error:
undefined entity at line 16, column 12, byte 547 at d:\system\iw-home\iw-perl\vendor\lib/XML/Parser.pm line 187
It is the it does not like - have put the <iw_pt /> at the very top of the doc as you suggested but it seems not to work.
any ideas would be greatly appreciated.
regards
Derek
Adam Stoller
Within the PT the text has already been partially processed / encoded so as to not upset the XML parser - the '&' in ' ' is not a legal character in the XML parsing.
You could try using '&nbsp;' instead - or - figure out how the ' ' has been encoded (perhaps it's a #**** string or a \****\**** pair of chars or something) and use that in your regex inside the PT instead - or - perhaps the use of a separate module for doing that part of the processing - where the module's code is not actually parsed / seen by the XML parser (as embeded perl code is)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
derekjohnston
Hi Fish,
Thanks for that it now works
regards
Derek
Adam Stoller
Since I suggested several possibilities - perhaps you could explain which one you chose or how you modified your code (with or without respect to what I suggested) to make it work - so that other's may benefit from the information?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com