HTML Encoding the string will likely alter its length.

If you were expecting the content to be 100 characters that change will 
probably not be significant, but when you’re looking for 10 characters encoding 
an “&” to “&” arbitrarily removes 40% of your capacity.

 

It should be obvious by now that using a render tag is not the way to solve 
this problem.

Are you publishing to PHP or ASPX? Use the runtime language support to alter 
the display on the fly.

Are you publishing to HTML? Use JavaScript.

 

You’re breaking a walnut with explosives.

 

 

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jian Huang
Sent: Tuesday, 16 June 2015 3:11 AM
To: [email protected]
Subject: Re: Comparing a string length

 

Hi Neil,

 

The new line or carriage return within txt_content is probably breaking the 
format of your rendertag.

 

http://simplyreddot.blogspot.com/2014/05/rendertag-to-escape-double-quote-and.html

 

Try this instead.

 

<%!! Escape:HtmlEncode(<%txt_body%>).Length !!%>


On Monday, June 15, 2015 at 11:12:24 AM UTC-4, Hilmar Bunjes wrote:

Hi Neil,

if you write this:

 

Escape:Text(txt_content).Length


you get the length of the String "txt_content" which should result in 11 
characters. However, I'm not sure why you get "Less then 10" (which is in fact 
"Less than or equal 10").

 

A slightly better solution for this problem could be to not insert the text 
placeholder into the page but to grab it from the RenderTag directly. This way 
you do not need any Escaping and do not run into problems with characters in 
the element that break the RenderTag. You can get an element of the current 
page this way (this should print out the length of the element txt_teaser):

 

<%!! Context:CurrentPage.GetElementByName(txt_teaser).Value.Length !!%>


If you are using an element transfered via list/dyn anchor you need to get the 
page first and then the element (the inf_... is an info element to get the guid 
of the page which is iterated in the list):

 

<%!! Context:Pages.GetPage(Guid:<%inf_PageGUID%>).GetElementByName... !!%>


Best,

Hilmar

 

-- 

www.smartapi.de <http://www.smartapi.de>  - RedDot RQL via .NET - 
object-oriented, well-tested and open source


Am Montag, 15. Juni 2015 10:42:02 UTC+2 schrieb Neil:

Hi all, thanks for the replies (including those off-list).

 

This is 11.2 Build 11.2.2.844 (11.2 SP2 HF6).

 

I got an off-list suggestion to change '...(<%txt_content%>)...' to just 
'...(txt_content)...', which got the comparison to at least render the output 
message.

 

It returned 'Less than 10' as the message, despite being over 2,000 chars, so 
something still not right:

 

<if>

        <query valuea="Escape:Text(txt_content).Length" operator="&gt;" 
valueb="Int:10">

            <htmltext>------ Over 10 ------</htmltext>

        </query>

        <query type="else">

            <htmltext>------ Less than 10 ------</htmltext>

        </query>

    </if>

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"RedDot CMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] 
<mailto:[email protected]> .
To post to this group, send email to [email protected] 
<mailto:[email protected]> .
Visit this group at http://groups.google.com/group/reddot-cms-users.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"RedDot CMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/reddot-cms-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to