Support Forum
Mr Papa said
Yes, I know... why I said that quick piece of code wouldnt do it...
Thanks anyway, you helped a lot with giving the assists.
I've got some help form the person who wrote the first code. It was for him much easier to implement a code via your filter tip. Below the code. Maybe it's interesting for you also for a new plugin or something.
The code removes the extra blockquote when you "Submit Reply". Then just one blockquote will be published, the last one of course.
# beursklets content filter
function spbeursklets_context_filter($content) {
# If exists more than 1 <blockquote> tag, remove "inner-blockquotes"
$bqcount = substr_count($content, '<blockquote>');
if ($bqcount >= 2) {
# Find second <blockquote> tag and prefix with own tag
$count = 0;
$pos = 0;
while ($count < 2) {
$pos = strpos($content, '<blockquote>', $pos);
if ($pos === false) {
$count = 100;
} else {
$pos++;
$count++;
if ($count > 1) {
$content = substr_replace($content, '<[REMOVE_MARKER]>', $pos - 1, 0);
}
}
}
# Find (last - 1) </blockquote> tag, if exists more than 1 and suffix with own tag
$count = 0;
$pos = 0;
while ($count < ($bqcount - 1)) {
$pos = strpos($content, '</blockquote>', $pos);
if ($pos === false) {
$count = $bqcount + 100;
} else {
$pos++;
$count++;
if ($count == ($bqcount - 1)) {
$content = substr_replace($content, '</[REMOVE_MARKER]>', $pos + strlen('</blockquote>') - 1, 0);
}
}
}
$content = preg_replace('/\<\[REMOVE_MARKER\]\>((.|\n|\r)*)\<\/\[REMOVE_MARKER\]\>/i', '', $content);
}
return $content;
}
?>
ah, the old fashioned brute force method... thanks for the update - saves me figuring out the negative look ahead regexp!
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)