PHP has functions to truncate strings. So the processing steps would be:
1) Do not use the title of the lesson directly, but first assign it to a variable.
2) Truncate the variable (if it is already short, you get back the full title).
3) Use the truncated variable where you originally used the title.
a lesson with a long title can be truncated before display.
PS: When truncation happens, one can get fancy and add ellipses (…) to indicate the occurrence of the truncation.
PPS: If you do not want to truncate and insist on showing the full title, then you would need to wrap the title. This too can be done with php. I did not see the exact manner in which a long title messes up the display so cannot say more. If you have a picture of the messed up display of long titles, I might be able to say more.
I noticed you have implemented truncation; there are two things that can be done to the present scheme, one to make it safer and the other to make it better. You may already have the “make it safer” thingy in place (can’t tell by the display). Will elaborate sometime today.
Earlier today, I said there are two things that could be done to the present scheme for displaying the author’s name and title of post in the Recent Comments box.
1) The first is that the length of the author might need to be truncated too — for example, there was a time when PK had a very long name, it was something like, “PK Vote Marina for sexiest geek”. You might already being doing this.
2) The second was that rather than truncate the author and title at a fixed length, it might be better to first truncate the author at a fixed length and to then truncate the title based (not on the length of the title but based) on the lenght of the line “$the_aurhor in $the_title”. This way, if the author’s name is short, then more characters can be used for the title.
I was going to provide php code, but gave up after I could not come up with a good php scheme to determine the length of a string! There are two issues with determining the length of a string:
A) What we want is the width in pixels (or inches) required to display $the_author (to see how the same number of characters can take up different lenghts on the display, see the lenghts of these two strings of 4 characters: “mmmm” and “nnnn”.).
The lenght of the display depends on the font being used — and it is not worth creating a general function to determine the display length of a given string in a given font. Here’s an example of such a function for a particular font (Verdana, 10px, non-bold) http://www.php.net/manual/en/function.strlen.php#76043
B) The next best thing (to working with width in pixels or inches) is to work with width being the number of characters. But php’s “strlen( $the_author);” function returns the number of bytes required to store $the_author (for people knowing C, php’s strlen() does not include any terminating null) which need not equal the number of visible characters in $the_author. When $the_author is “Hs4Mm”, strlen( $the_aurhor ) returns 5 which is the number of displayed characters; but when $the_author = “Марина Орлова”; strlen( $the_aurhor ) returns a number bigger than 13 (the number of bytes required to store the 13 visible characters in “Марина Орлова”).
I am at a loss as to how to handle strings with non-ASCII characters. I tried various experiments along the lines indicated below but none of them worked!
Supposedly, one can determine number of visible characters via the function:
The code tag was not parsed properly; trying again with tags between each line:
Supposedly, one can determine number of visible characters via the function:
$the_length = strlen( utf8_decode( utf8_encode( $the_string ) ) );
// preceding should return 13
Supposedly, one can also use the "/u" modifier to search patterns ( http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php ):
$max_length = 20;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 1
$max_length = 10;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 0
There’s lots of creative ways to insult someone back; “Yo, hey turdsatchel, your bag is full.” “When’s the last time you sat down on a clean toilet seat and let loose a big ripe juicy frapple outta yer crap sack ya nutmegbag !”
Now THERE’s a word I’ve requested more than once in the past. But more specifically, what’s the plural form of [DUFUS]?
I always thought it sounded pretty weird when people were collectively described as “dufuses” as in: “There’s a pair of real dufuses.”
So I figured the best way to pluralize it was to use the Latin convention where the “-us” suffix would be changed to a long “I” sound, resulting in statements such as “There goes a whole bus-load of DUFI.” Now doesn’t that sound a lot better?
Oh, okay. Funny word that [DUFUS] Couldn’t tell ya what the plural of dufus is but I had a hearty chuckle at DUFI!
I’ve heard it used as DOOF as in GOOF & GOOFBALL but rarely as DOOFBALL.
HOMEWORK: There’s always scumbag or the great English word rotter (which for some reason makes me think of the actor Terry-Thomas, who played [cads] of the first order).
My mother always called it a Hot Water Bottle. She would remove the hose and orface tube and put a cap on the bottle allowing it to used as a appliance to place be on sore muscles or for earaches. It also comes in Book Form.
–Funny–why not me …A bag of potatoes are not the same the second time around…deadly nightshade and the tobacco plant makes me fill my pants; she said that in a secret memo….[pelting] tomatoes makes to fill-up on soup supplies
Test to see if <code> is supported: Will try to print > within <code> and </code> tag.
can I use > directly: > ?
Yes! Thanks a lot!
Harder test:
non_existent_image.jpg
blah blah
should not end up as a link
Harder test failed! <code> … </code> does not work
Maybe that test was too hard. Slightly hard test:
function truncate_to( $the_string, $max_length )
{
$the_length = // correct way to get length -- NOT strlen( )
if( $the_lenght <= $max_length ) return $the_string;
}
echo "author (85 bytes):$the_author," . strlen($the_author) . ',' . strlen( utf8_decode( $the_author ) ) . ',' . "";
if ( !preg_match('/^\w{,30}$/u', $the_author) )
{
echo "author is over 30";
}
OK, that’s good enough! To make a tinsy bit harder, since html tags are rejected, see if php tags are accepted:
Maybe I forgot something in the tinsy bit harder test; try again:
Homework: Vag-O-matic.
Так смешно, Марина!!! Cамом деле!!! Super! So funny!
Привет из Москвы…от “lovelyman1968″ (struggling there to learn Russian). Пока!
Here is a comment in a post with a really long title.
hmmm
Hello there wordsmith
OK.. that doesn’t work.. I guess I can’t show the title of the post where the comments are happening yet. Hmm..
PHP has functions to truncate strings. So the processing steps would be:
1) Do not use the title of the lesson directly, but first assign it to a variable.
2) Truncate the variable (if it is already short, you get back the full title).
3) Use the truncated variable where you originally used the title.
a lesson with a long title can be truncated before display.
PS: When truncation happens, one can get fancy and add ellipses (…) to indicate the occurrence of the truncation.
PPS: If you do not want to truncate and insist on showing the full title, then you would need to wrap the title. This too can be done with php. I did not see the exact manner in which a long title messes up the display so cannot say more. If you have a picture of the messed up display of long titles, I might be able to say more.
I don’t know how to do that.. I’ll look and see if I can find out how.
I have this variable.. how do I assign it to another variable and truncate it? get_the_title($comment->comment_post_ID);
Reply notification did not work for the two replies you made below; saw them just now. I’ll provide details sometime today.
I noticed you have implemented truncation; there are two things that can be done to the present scheme, one to make it safer and the other to make it better. You may already have the “make it safer” thingy in place (can’t tell by the display). Will elaborate sometime today.
Earlier today, I said there are two things that could be done to the present scheme for displaying the author’s name and title of post in the Recent Comments box.
1) The first is that the length of the author might need to be truncated too — for example, there was a time when PK had a very long name, it was something like, “PK Vote Marina for sexiest geek”. You might already being doing this.
2) The second was that rather than truncate the author and title at a fixed length, it might be better to first truncate the author at a fixed length and to then truncate the title based (not on the length of the title but based) on the lenght of the line “$the_aurhor in $the_title”. This way, if the author’s name is short, then more characters can be used for the title.
I was going to provide php code, but gave up after I could not come up with a good php scheme to determine the length of a string! There are two issues with determining the length of a string:
A) What we want is the width in pixels (or inches) required to display $the_author (to see how the same number of characters can take up different lenghts on the display, see the lenghts of these two strings of 4 characters: “mmmm” and “nnnn”.).
The lenght of the display depends on the font being used — and it is not worth creating a general function to determine the display length of a given string in a given font. Here’s an example of such a function for a particular font (Verdana, 10px, non-bold) http://www.php.net/manual/en/function.strlen.php#76043
B) The next best thing (to working with width in pixels or inches) is to work with width being the number of characters. But php’s “strlen( $the_author);” function returns the number of bytes required to store $the_author (for people knowing C, php’s strlen() does not include any terminating null) which need not equal the number of visible characters in $the_author. When $the_author is “Hs4Mm”, strlen( $the_aurhor ) returns 5 which is the number of displayed characters; but when $the_author = “Марина Орлова”; strlen( $the_aurhor ) returns a number bigger than 13 (the number of bytes required to store the 13 visible characters in “Марина Орлова”).
I am at a loss as to how to handle strings with non-ASCII characters. I tried various experiments along the lines indicated below but none of them worked!
Supposedly, one can determine number of visible characters via the function:
$the_length = strlen( utf8_decode( utf8_encode( $the_string ) ) );
// preceding should return 13
Supposedly, one can also use the "/u" modifier to search patterns ( http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php ):
$max_length = 20;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 1
$max_length = 10;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 0
The code tag was not parsed properly; trying again with tags between each line:
Supposedly, one can determine number of visible characters via the function:
$the_length = strlen( utf8_decode( utf8_encode( $the_string ) ) );
// preceding should return 13
Supposedly, one can also use the "/u" modifier to search patterns ( http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php ):
$max_length = 20;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 1
$max_length = 10;
$is_short = preg_match( '/^.{1,$max_length}$/u', uft8_encode( $the_author ) ) );
// preceding should return 0
There’s lots of creative ways to insult someone back; “Yo, hey turdsatchel, your bag is full.” “When’s the last time you sat down on a clean toilet seat and let loose a big ripe juicy frapple outta yer crap sack ya nutmegbag !”
Another bad name to call someone? I know too many of those already.
How about showerbag? Shower pretty much means the same thing as douche.
Testing posting a comment from my phone with this new phone theme. Can’t reply to someone but it is awesome
By chance…I’ll test to you..
@HotForWords
Marina,
You just got a mention on the Factor. O’ Reilly wants you back so you can do the word origin for Doofus
Now THERE’s a word I’ve requested more than once in the past. But more specifically, what’s the plural form of [DUFUS]?
I always thought it sounded pretty weird when people were collectively described as “dufuses” as in: “There’s a pair of real dufuses.”
Oh, okay. Funny word that [DUFUS] Couldn’t tell ya what the plural of dufus is but I had a hearty chuckle at DUFI!
I’ve heard it used as DOOF as in GOOF & GOOFBALL but rarely as DOOFBALL.
The comments are in Bizzaro World. You have reverse the order.
alax’s bright idea
http://www.hotforwords.com/2009/09/09/agent-provocateur/#comment-151260
Some fellow in the army from New Jersey used the expression DOUCHEBAG!
a word meaning “arrogant, self-important, attention-grubbing, pathologically deceitful compulsive stealer?” how about “Obama”?
HOMEWORK: There’s always scumbag or the great English word rotter (which for some reason makes me think of the actor Terry-Thomas, who played [cads] of the first order).
Change the nozzle and it’s and ‘enema bag’
My mother always called it a Hot Water Bottle. She would remove the hose and orface tube and put a cap on the bottle allowing it to used as a appliance to place be on sore muscles or for earaches. It also comes in Book Form.
hey Marina
high five
or wave hello 
have a great day B.B. 
H/W hot crotch cleaner or leg joint washer????
Boink! Boink! Boink!!
Darse una ducha – Spanish for to take a shower
hmmm, an alternative word for douchebag. homework: douchepad, doucherag, douchesponger, douchesod, douchemootch
Hey beautiful
I did not figure on with the comment at “G4 TV’s Attack of the show: Douchebag”…
americana