Doing something like 'Suppress Trailing Spaces on Empty Content' with XM

299 views
Skip to first unread message

thomaus

unread,
Apr 10, 2013, 3:10:50 PM4/10/13
to xmpie...@googlegroups.com
We'd like to collapse lines on an email like it happens in InDesign with Dynamic Story Properties & Suppress Trailing Spaces.

Borrowing some code from the XM RURL wizard templates we tried this:

<% if (!string.IsNullOrEmpty("<%# /* Text ADOR */ AdorRec.FieldValue("SG_Phone", Container) %>"))
{ %> 
 <%# /* Text ADOR */ AdorRec.FieldValue("SG_Phone", Container) %><br />
<% } %> 

But the page errors with: CS1010: Newline in constant

We've played around with the quote marks, single & double, and also tried null instead of Container and still see the error.

This seems to work: 

<% if(AdorRec.FieldValue("SG_Phone", null) != "")
 { %> 
<%# /* Text ADOR */ AdorRec.FieldValue("SG_Phone", Container) %><br />
<% } %>

But will it catch all the varieties of blank that IsNullOrEmpty would?

Guillaume Besnier

unread,
Apr 10, 2013, 5:33:44 PM4/10/13
to xmpie...@googlegroups.com
I would try the following:

<%# ( ! String.IsNullOrEmpty(AdorRec.FieldValue("SG_Phone", Container))) ? AdorRec.FieldValue("SG_Phone", Container) + "<br />" : "" %>

-------- Message original --------
Sujet: [xmpie-users] Doing something like 'Suppress Trailing Spaces on Empty Content' with XM
De : thomaus <thomau...@gmail.com>
Pour : xmpie...@googlegroups.com
Date : 10/04/2013 21:10
--
You received this message because you are subscribed to the Google Groups "XMPie Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xmpie-users...@googlegroups.com.
To post to this group, send email to xmpie...@googlegroups.com.
Visit this group at http://groups.google.com/group/xmpie-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

thomaus

unread,
Apr 10, 2013, 5:51:24 PM4/10/13
to xmpie...@googlegroups.com
That works perfectly. And it's more elegant than our other attempts. 
Is String.IsNullOrEmpty a better test than !="" in practice? Our data could have either no text or NULLs in place, so it seems like it would be better.

Thanks.

On Wednesday, 10 April 2013 17:33:44 UTC-4, Bill wrote:
I would try the following:

<%# ( ! String.IsNullOrEmpty(AdorRec.FieldValue("SG_Phone", Container))) ? AdorRec.FieldValue("SG_Phone", Container) + "<br />" : "" %>

-------- Message original --------
Sujet: [xmpie-users] Doing something like 'Suppress Trailing Spaces on Empty Content' with XM
De : thomaus <thoma...@gmail.com>

Pour : xmpie...@googlegroups.com
Date : 10/04/2013 21:10

Guillaume Besnier

unread,
Apr 11, 2013, 4:16:36 PM4/11/13
to xmpie...@googlegroups.com
I would indeed use String.IsNullOrEmpty() rather than just comparing against an empty string.

-------- Message original --------
Sujet: Re: [xmpie-users] Doing something like 'Suppress Trailing Spaces on Empty Content' with XM
Date : 10/04/2013 23:51

Igor

unread,
Apr 11, 2013, 4:21:06 PM4/11/13
to xmpie...@googlegroups.com
if you do not know C# I'd recommend not to modify stuff , but  same using built in features.
For example you can expose visibility ADOR that will hide DIV based on QLingo IsNullOrEmpty .

KA

unread,
Apr 17, 2013, 5:09:11 PM4/17/13
to xmpie...@googlegroups.com
Another kind of slacker way to deal with this is to add an additional ADOR that displays the <br/> tag, or not, depending on whether there is content in the data field. Then you place the ADOR for your text in the document, followed (in the code view) by the ADOR for the break.

So, for example, your first ADOR is "ADDRESS2" with the contents of simply
|->[ADDRESS2]

Your second ADOR is "ADDRESS2_BR" with the contents of:

if(Length(|->[ADDRESS2]) > 1)
{  "<br/>" }
else
{ "" }

And in the Dreamweaver code you place them end to end where you want the text to show:
<%# /* Text ADOR */ AdorRec.FieldValue("ADDRESS2", Container) %><%# /* Text ADOR */ AdorRec.FieldValue("ADDRESS2_BR", Container) %>

Be sure to drag the ADDRESS2_BR into the "code view " in Dreamweaver so that you don't end up with the text "<br/>" showing up on the page as text.

Then put your next line of text on the same line (i.e. not after a <br/> tag)

If they are both empty, then nothing shows in the Dreamweaver page in that area. If they are both full, you get your new text plus the line break.

Kristin
Reply all
Reply to author
Forward
0 new messages