Hi guys,

My bad, I lost sight of the question.

-Jian

On Tuesday, June 16, 2015 at 5:28:32 AM UTC-4, Hilmar Bunjes wrote:
>
>  Hi Richard,
> Ok, now I get what you mean and I totally agree: if the problem is 
> displaying too much content in an HTML element this is not the right way to 
> do. 
>
>  I've made very good experience with this JavaScript to shorten the 
> content to the size of an element: http://dotdotdot.frebsite.nl The CSS 
> wrapping never has worked the way I wanted it to work but this does. 
>
>  Best
> Hilmar
>
>  
>
> Sent via mobile phone
>
> Am 16.06.2015 um 10:54 schrieb Richard Hauer <richar...@gmail.com 
> <javascript:>>:
>
>   Well, getting the element content via the RenderTag will not alter the 
> length, but HTML encoding it definitely will.
>
>  
>
> Observe…
>
>  
>
> "UP & DOWN"   - 11 characters
>
> &quot;UP&amp; DOWN&quot; - 24 characters
>
>  
>
> Your solution is much better than Jian’s, though I suspect measuring the 
> length of the string is not really the goal of Neil’s task at all.  I 
> expect there is an element on the page that is quite small (physically 
> speaking) and can only accommodate a small amount of content.  Measuring 
> the length of the content is a hack often used to swap out a small display 
> element with a larger one that can handle longer text.  This is a bad idea 
> for lots of reasons, but chief among them is that characters are not all 
> the same width, so measuring the number of characters does not actually 
> meet the requirement at all, which is (and I’m guessing) to measure the *
> *width** of the characters.
>
>  
>
> Both 10 characters:
>
> IIIIIIIIII
>
> vs
>
> WWWWWWWWWW
>
>  
>
> This type of problem is handled much better with CSS (and the client-side 
> code you are clearly not fond of) as the browser knows exactly how wide 
> that content is going to be for the given device/orientation/zoom/font and 
> can make adjustments as appropriate. 
>
>  
>
> At any rate all that is moot as the actual question was about measuring 
> the length of the string.
>
> Neil, if it **HAS** to be done in a render tag, do it Hilmar’s way 
> (assuming you haven’t already).
>
>  
>
> /R
>
>  
>
>  
>
> *From:* reddot-c...@googlegroups.com <javascript:> [
> mailto:redd...@googlegroups.com <javascript:>] *On Behalf Of *Hilmar 
> Bunjes
> *Sent:* Tuesday, 16 June 2015 5:59 PM
> *To:* reddot-c...@googlegroups.com <javascript:>
> *Subject:* Re: Comparing a string length
>
>  
>  
> Richard,
>  
> getting the element content via RenderTag should not alter the content of 
> the string, does it?
>  
>  
>  
> Don't you think <%!! Context:CurrentPage.GetElementByName(txt_teaser).
> Value.Length !!%> should solve this issue? 
>  
>  
>  
> I think the explosives are server-side or client-side programming instead 
> of using RenderTags :-)
>  
>  
>  
> Best,
>  
> Hilmar
>  
>
> Am Dienstag, 16. Juni 2015 09:52:10 UTC+2 schrieb Richard Hauer (5 Limes):
>
>  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 “&amp;” 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:* reddot-c...@googlegroups.com [mailto:reddot-c...@googlegroups.com] 
> *On Behalf Of *Jian Huang
> *Sent:* Tuesday, 16 June 2015 3:11 AM
> *To:* reddot-c...@googlegroups.com
> *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 - 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 reddot-cms-use...@googlegroups.com.
> To post to this group, send email to reddot-c...@googlegroups.com.
> 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 reddot-cms-use...@googlegroups.com <javascript:>.
> To post to this group, send email to reddot-...@googlegroups.com 
> <javascript:>.
> 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 a topic in the 
> Google Groups "RedDot CMS Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/reddot-cms-users/LkHGVcA8uNY/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to 
> reddot-cms-us...@googlegroups.com <javascript:>.
> To post to this group, send email to reddot-...@googlegroups.com 
> <javascript:>.
> 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 reddot-cms-users+unsubscr...@googlegroups.com.
To post to this group, send email to reddot-cms-users@googlegroups.com.
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