Re: [WebDNA] Count Lines

This WebDNA talk-list message is from

2011


It keeps the original formatting.
numero = 106626
interpreted = N
texte = This is a multi-part message in MIME format. --------------000109070404040305000401 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit countchars is one way... WebDNA has no way of knowing how elements are being displayed in your browser since it is strictly a server-side language. To to get exactly what you want, you'll have to use client-side scripting by DOM javascript and css. First, in your css, define the lineheight of the text and height of the div. Javascript can also get these values without you setting them. Using DOM scripting, jQuery, or whatever script library you like: you'll need to use "offsetHeight" to get the div height and "style.lineHeight" to get the lineHeight Then divide these numbers to get the number of lines Insert a "show More" link dynamically On 5/10/11 6:05 AM, Steve Craig wrote: > Not sure if this helps but I use it in a news page where the user > gets, in my case, the first 150 characters but trimmed to the nearest > full word. > > [if [countchars][mySTORY][/countchars]>150] > [then] > [listwords delimiters= &words=[url][getchars > start=1&end=150][mySTORY][/getchars][/url]][text]word[math][index]+1[/math]=[word][/text][text]word[index][/text] > [/listwords] > (Click for more...) > [/then] > [else][mySTORY][/else] > [/if] > > Hope it helps. > > Cheers > ======================================== > Steve Craig - Asylum Interactive Ltd > Tel +44 1330 860550 Fax +44 1330 860880 > ======================================== > http://www.asylumweb.com > Email: steve@asylumweb.com > Skype: s.craig - iChat: steve.craig > ======================================== > > > > > On 10 May 2011, at 00:22, Stuart Tremain wrote: > >> It just autowraps in the div so there is no specific marker to use. >> >> I have a div with text loaded from a database in it. I have no >> control over the length of the text and want to calculate or count >> the number of lines it wraps to so I can hide all except a small >> segment at the beginning until a user clicks on "more". >> >> I am using a show more link to expand the div to show the rest of the >> text but if there is not enough text, there is no need to show the >> "show more" >> >> Here's is an example of what I am doing: >> In this case the "more info" is required >> http://www.top3.com.au/designers/ben-mccarthy/ >> >> But here it is not, I need a way of determining if it needs to be >> shown, counting chars is not accurate enough. >> http://www.top3.com.au/designers/adam-goodrum/ >> >> >> >> On 09/05/2011, at 9:40 PM, William DeVaul wrote: >> >>> What defines the lines? Is it something like counting 80 characters >>> or carriage returns? >>> >>> On Mon, May 9, 2011 at 7:07 AM, Stuart Tremain >> > wrote: >>>> I have a problem where I need to count the lines of text in a >>>>
, the contents are dynamic from a DB. >>>> >>>> Any ideas ? >>>> >>>> Regards >>>> >>>> Stuart Tremain >>>> IDFK Web Developments >>>> AUSTRALIA >>>> webdna@idfk.com.au >>>> >>>> >>>> >>>> >>>> --------------------------------------------------------- >>>> This message is sent to you because you are subscribed to >>>> the mailing list >. >>>> To unsubscribe, E-mail to: >>> > >>>> archives: http://mail.webdna.us/list/talk@webdna.us >>>> Bug Reporting: support@webdna.us >>>> >>> --------------------------------------------------------- >>> This message is sent to you because you are subscribed to >>> the mailing list >. >>> To unsubscribe, E-mail to: >> > >>> archives: http://mail.webdna.us/list/talk@webdna.us >>> Bug Reporting: support@webdna.us >> >> --------------------------------------------------------- This >> message is sent to you because you are subscribed to the mailing list >> . To unsubscribe, E-mail to: archives: >> http://mail.webdna.us/list/talk@webdna.us Bug Reporting: >> support@webdna.us > > --------------------------------------------------------- This message > is sent to you because you are subscribed to the mailing list . To > unsubscribe, E-mail to: archives: > http://mail.webdna.us/list/talk@webdna.us Bug Reporting: > support@webdna.us --------------000109070404040305000401 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit countchars is one way...

WebDNA has no way of knowing how elements are being displayed in your browser since it is strictly a server-side language.  To to get exactly what you want, you'll have to use client-side scripting by DOM javascript and css.

First, in your css, define the lineheight of the text and height of the div.  Javascript can also get these values without you setting them. 

Using DOM scripting, jQuery, or whatever script library you like:
you'll need to use "offsetHeight" to get the div height and "style.lineHeight" to get the lineHeight
Then divide these numbers to get the number of lines
Insert a "show More" link dynamically






On 5/10/11 6:05 AM, Steve Craig wrote:
Not sure if this helps but I use it in a news page where the user gets, in my case, the first 150 characters but trimmed to the nearest full word.

[if [countchars][mySTORY][/countchars]>150]
[then]
  [listwords delimiters= &words=[url][getchars start=1&end=150][mySTORY][/getchars][/url]][text]word[math][index]+1[/math]=[word][/text][text]word[index][/text] [/listwords]
  <a href="myMoreLink" >(Click for more...)</a>
[/then]
[else][mySTORY][/else]
[/if]

Hope it helps.

Cheers
========================================
Steve Craig - Asylum Interactive Ltd
Tel +44 1330 860550 Fax +44 1330 860880
========================================
Email: steve@asylumweb.com
Skype: s.craig - iChat: steve.craig
========================================




On 10 May 2011, at 00:22, Stuart Tremain wrote:

It just autowraps in the div so there is no specific marker to use.

I have a div with text loaded from a database in it. I have no control over the length of the text and want to calculate or count the number of lines it wraps to so I can hide all except a small segment at the beginning until a user clicks on "more".

I am using a show more link to expand the div to show the rest of the text but if there is not enough text, there is no need to show the "show more"

Here's is an example of what I am doing:
In this case the "more info" is required
http://www.top3.com.au/designers/ben-mccarthy/

But here it is not, I need a way of determining if it needs to be shown, counting chars is not accurate enough.
http://www.top3.com.au/designers/adam-goodrum/



On 09/05/2011, at 9:40 PM, William DeVaul wrote:

What defines the lines?  Is it something like counting 80 characters
or carriage returns?

On Mon, May 9, 2011 at 7:07 AM, Stuart Tremain <webdna@idfk.com.au> wrote:
I have a problem where I need to count the lines of text in a <DIV>, the contents are dynamic from a DB.

Any ideas ?

Regards

Stuart Tremain
IDFK Web Developments
AUSTRALIA
webdna@idfk.com.au




---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list <talk@webdna.us>.
To unsubscribe, E-mail to: <talk-leave@webdna.us>
archives: http://mail.webdna.us/list/talk@webdna.us
Bug Reporting: support@webdna.us

---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list <talk@webdna.us>.
To unsubscribe, E-mail to: <talk-leave@webdna.us>
archives: http://mail.webdna.us/list/talk@webdna.us
Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us
--------------000109070404040305000401-- Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Count Lines (Stuart Tremain 2011)
  2. Re: [WebDNA] Count Lines (Olin Lagon 2011)
  3. Re: [WebDNA] Count Lines (Aaron Michael Kaczmarek 2011)
  4. Re: [WebDNA] Count Lines (Steve Craig 2011)
  5. Re: [WebDNA] Count Lines (Stuart Tremain 2011)
  6. Re: [WebDNA] Count Lines (William DeVaul 2011)
  7. Re: [WebDNA] Count Lines (Tom Duke 2011)
  8. [WebDNA] Count Lines (Stuart Tremain 2011)
This is a multi-part message in MIME format. --------------000109070404040305000401 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit countchars is one way... WebDNA has no way of knowing how elements are being displayed in your browser since it is strictly a server-side language. To to get exactly what you want, you'll have to use client-side scripting by DOM javascript and css. First, in your css, define the lineheight of the text and height of the div. Javascript can also get these values without you setting them. Using DOM scripting, jQuery, or whatever script library you like: you'll need to use "offsetHeight" to get the div height and "style.lineHeight" to get the lineHeight Then divide these numbers to get the number of lines Insert a "show More" link dynamically On 5/10/11 6:05 AM, Steve Craig wrote: > Not sure if this helps but I use it in a news page where the user > gets, in my case, the first 150 characters but trimmed to the nearest > full word. > > [if [countchars][mySTORY][/countchars]>150] > [then] > [listwords delimiters= &words=[url][getchars > start=1&end=150][mySTORY][/getchars][/url]][text]word[math][index]+1[/math]=[word][/text][text]word[index][/text] > [/listwords] > (Click for more...) > [/then] > [else][mySTORY][/else] > [/if] > > Hope it helps. > > Cheers > ======================================== > Steve Craig - Asylum Interactive Ltd > Tel +44 1330 860550 Fax +44 1330 860880 > ======================================== > http://www.asylumweb.com > Email: steve@asylumweb.com > Skype: s.craig - iChat: steve.craig > ======================================== > > > > > On 10 May 2011, at 00:22, Stuart Tremain wrote: > >> It just autowraps in the div so there is no specific marker to use. >> >> I have a div with text loaded from a database in it. I have no >> control over the length of the text and want to calculate or count >> the number of lines it wraps to so I can hide all except a small >> segment at the beginning until a user clicks on "more". >> >> I am using a show more link to expand the div to show the rest of the >> text but if there is not enough text, there is no need to show the >> "show more" >> >> Here's is an example of what I am doing: >> In this case the "more info" is required >> http://www.top3.com.au/designers/ben-mccarthy/ >> >> But here it is not, I need a way of determining if it needs to be >> shown, counting chars is not accurate enough. >> http://www.top3.com.au/designers/adam-goodrum/ >> >> >> >> On 09/05/2011, at 9:40 PM, William DeVaul wrote: >> >>> What defines the lines? Is it something like counting 80 characters >>> or carriage returns? >>> >>> On Mon, May 9, 2011 at 7:07 AM, Stuart Tremain >> > wrote: >>>> I have a problem where I need to count the lines of text in a >>>>
, the contents are dynamic from a DB. >>>> >>>> Any ideas ? >>>> >>>> Regards >>>> >>>> Stuart Tremain >>>> IDFK Web Developments >>>> AUSTRALIA >>>> webdna@idfk.com.au >>>> >>>> >>>> >>>> >>>> --------------------------------------------------------- >>>> This message is sent to you because you are subscribed to >>>> the mailing list >. >>>> To unsubscribe, E-mail to: >>> > >>>> archives: http://mail.webdna.us/list/talk@webdna.us >>>> Bug Reporting: support@webdna.us >>>> >>> --------------------------------------------------------- >>> This message is sent to you because you are subscribed to >>> the mailing list >. >>> To unsubscribe, E-mail to: >> > >>> archives: http://mail.webdna.us/list/talk@webdna.us >>> Bug Reporting: support@webdna.us >> >> --------------------------------------------------------- This >> message is sent to you because you are subscribed to the mailing list >> . To unsubscribe, E-mail to: archives: >> http://mail.webdna.us/list/talk@webdna.us Bug Reporting: >> support@webdna.us > > --------------------------------------------------------- This message > is sent to you because you are subscribed to the mailing list . To > unsubscribe, E-mail to: archives: > http://mail.webdna.us/list/talk@webdna.us Bug Reporting: > support@webdna.us --------------000109070404040305000401 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit countchars is one way...

WebDNA has no way of knowing how elements are being displayed in your browser since it is strictly a server-side language.  To to get exactly what you want, you'll have to use client-side scripting by DOM javascript and css.

First, in your css, define the lineheight of the text and height of the div.  Javascript can also get these values without you setting them. 

Using DOM scripting, jQuery, or whatever script library you like:
you'll need to use "offsetHeight" to get the div height and "style.lineHeight" to get the lineHeight
Then divide these numbers to get the number of lines
Insert a "show More" link dynamically






On 5/10/11 6:05 AM, Steve Craig wrote:
Not sure if this helps but I use it in a news page where the user gets, in my case, the first 150 characters but trimmed to the nearest full word.

[if [countchars][mySTORY][/countchars]>150]
[then]
  [listwords delimiters= &words=[url][getchars start=1&end=150][mySTORY][/getchars][/url]][text]word[math][index]+1[/math]=[word][/text][text]word[index][/text] [/listwords]
  <a href="myMoreLink" >(Click for more...)</a>
[/then]
[else][mySTORY][/else]
[/if]

Hope it helps.

Cheers
========================================
Steve Craig - Asylum Interactive Ltd
Tel +44 1330 860550 Fax +44 1330 860880
========================================
Email: steve@asylumweb.com
Skype: s.craig - iChat: steve.craig
========================================




On 10 May 2011, at 00:22, Stuart Tremain wrote:

It just autowraps in the div so there is no specific marker to use.

I have a div with text loaded from a database in it. I have no control over the length of the text and want to calculate or count the number of lines it wraps to so I can hide all except a small segment at the beginning until a user clicks on "more".

I am using a show more link to expand the div to show the rest of the text but if there is not enough text, there is no need to show the "show more"

Here's is an example of what I am doing:
In this case the "more info" is required
http://www.top3.com.au/designers/ben-mccarthy/

But here it is not, I need a way of determining if it needs to be shown, counting chars is not accurate enough.
http://www.top3.com.au/designers/adam-goodrum/



On 09/05/2011, at 9:40 PM, William DeVaul wrote:

What defines the lines?  Is it something like counting 80 characters
or carriage returns?

On Mon, May 9, 2011 at 7:07 AM, Stuart Tremain <webdna@idfk.com.au> wrote:
I have a problem where I need to count the lines of text in a <DIV>, the contents are dynamic from a DB.

Any ideas ?

Regards

Stuart Tremain
IDFK Web Developments
AUSTRALIA
webdna@idfk.com.au




---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list <talk@webdna.us>.
To unsubscribe, E-mail to: <talk-leave@webdna.us>
archives: http://mail.webdna.us/list/talk@webdna.us
Bug Reporting: support@webdna.us

---------------------------------------------------------
This message is sent to you because you are subscribed to
the mailing list <talk@webdna.us>.
To unsubscribe, E-mail to: <talk-leave@webdna.us>
archives: http://mail.webdna.us/list/talk@webdna.us
Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us

--------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: archives: http://mail.webdna.us/list/talk@webdna.us Bug Reporting: support@webdna.us
--------------000109070404040305000401-- Aaron Michael Kaczmarek

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Mime Headers for Mail (1998) WebCat2: Items xx to xx shown, etc. (1997) How can I record purchases to a database? (1998) Nested tags count question (1997) can I get formvariables for an include? (1999) 2 databases problem (1997) calculating time (2002) God's Truth (1998) RE: Include (1998) Price characteristics? (1997) Boolean Tests with dereferenced arrays are broken in (2003) Imagemagick and fonts (2004) Re:Virtual hosting and webcatNT (1997) Ram usage (1999) Credit Card Number checking (1997) [interpret] inside the db field? (1997) Has anyone integrated ZipBurst with WebCat? (2000) Setting up WebCatalog with Retail Pro data (1996) cybercash on OSX - was Executing remote AppleScript (2000) normal users.db calls ... (1998)