Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 06:56 am EDT

Geeklog Forums

Keeping paragraphs in e-mail stories


Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
When you e-mail a story in Geeklog, profiles.php uses strip_tags on the article before adding it to the message text to be sent. For articles with paragraphing or other formating that uses br, the result is a solid block of text.

I've created a replacement function that (in my limited testing) fixes this problem and is easy to implement.

First, add this code to profiles.php after the include('lib-common.php') line.

function strip_tagsLB($text)
{
// replace line endings;
$text = str_replace('

',LB.LB, $text);
$text = str_replace('

',LB.LB, $text);
$text = str_replace('

',LB.LB, $text);
$text = str_replace('

',LB.LB, $text);
$text = str_replace('

',LB.LB, $text);
$text = str_replace('
',LB, $text);
$text = str_replace('
',LB, $text);
$text = str_replace('
',LB, $text);
$text = str_replace('
',LB, $text);

//strip remaining tags
$text = strip_tags($text);

return $text;
}
[/code]

Now search and replace the remainder of profiles.php, replacing all instances of strip_tags( with strip_tagsLB(

Be sure NOT to replace the strip_tags call in the function strip_tagsLB

As I've said I've only done limited testing, but this appears to maintain the paragraphing. Obviously, this can be customized further if you want to replace other HTML with line breaks.

 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Just thought I'd point out that we have this nice
Text Formatted Code
 ...
pseudo-tag in Geeklog now which is perfect for posting, well, code ;-) bye, Dirk
 Quote

Status: offline

jlhughes

Forum User
Full Member
Registered: 04/25/02
Posts: 154
OK, here's the coded version of the function.
Text Formatted Code

// HACK TO REPLACE strip_tags WITH LINE BREAKS
function strip_tagsLB($text)
{
// replace line endings;
$text = str_replace('<p>',LB.LB, $text);
$text = str_replace('<P>',LB.LB, $text);
$text = str_replace('<BR><BR>',LB.LB, $text);
$text = str_replace('<br><br>',LB.LB, $text);
$text = str_replace('<br /><br />',LB.LB, $text);
$text = str_replace('<BR>',LB, $text);
$text = str_replace('<br>',LB, $text);
$text = str_replace('<BR />',LB, $text);
$text = str_replace('<br />',LB, $text);

//strip remaining tags
$text = strip_tags($text);

return $text;
}
 
This version makes a lot more sense!
 Quote

All times are EDT. The time is now 06:56 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content