views:

51

answers:

1

You can set what the Facebook Share preview says. I would like it to be the first paragraph of my movable type entry. The people who make entries sometimes use

<p> 

tags or they use the rich editor which puts in two

<br /><br />

tags to separate paragraphs.

Is there a way I can have movable type detect when the first paragraph end and only display the first paragraph? I would like to add that to my entry template so it will add some information to my head.

A: 

The s/// operator is a good tool to delete everything in a string that appears after a paragraph break as you've described it:

$text_to_display = get_my_movable_type_entry();
$text_to_display =~ s!<\s*p\s*/?>.*!!i;            # trim everything after <p>,<p/>
$text_to_display =~ s!(<\s*br\s*/?>\s*){2}.*!!i;   # trim everything after two <br>,<br/>
mobrule