Does anyone know a PHP script to convert ampersands to its HTML entity (& amp;) in the comment body? I don't know PHP, so I've been manually editing comments to validate HTML.
I can see where I would need to insert it in components/com_chronocomments/templates/comment-item.html.php. Just don't know how to go about it to achieve the desired result. Thanks for any help.
Ben
I can see where I would need to insert it in components/com_chronocomments/templates/comment-item.html.php. Just don't know how to go about it to achieve the desired result. Thanks for any help.
Ben
Hi Ben,
It will be something like this
Bob
It will be something like this
$text = str_replace('&', '&', $text);
$text = str_replace('&', '&', $text);
The second line is to fix any existing &Bob
Thanks Bob. I understand the str_replace part.
If this is the section I want to edit:
How would I write the script?
Ben
If this is the section I want to edit:
<div class="comment-body">
{comment_text}
</div>
How would I write the script?
Ben
Hi Ben,
Sorry, can't help with that part. I've never dug into the ChronoComments code enough to understand how it works :-(
Bob
Sorry, can't help with that part. I've never dug into the ChronoComments code enough to understand how it works :-(
Bob
Hi Bob,
I figured it out. I added the 2 lines you suggested to /plugins/content/ChronoComments.php around line 341, after the bbcode and htmlcode arrays just above:
So the code looks like this:
Works like a charm. Thanks for your help!
Aloha,
Ben
Update: If you also have the module installed, the same must be done for /modules/mod_chronocomments/helper.php around lines 111 and 148.
I figured it out. I added the 2 lines you suggested to /plugins/content/ChronoComments.php around line 341, after the bbcode and htmlcode arrays just above:
$newtext = preg_replace($bbcode, $htmlcode, $text);
So the code looks like this:
$text = str_replace ('&', '&', $text);
$text = str_replace('&', '&', $text);
$newtext = preg_replace($bbcode, $htmlcode, $text);
$newtext = nl2br($newtext);
return $newtext;
Works like a charm. Thanks for your help!
Aloha,
Ben
Update: If you also have the module installed, the same must be done for /modules/mod_chronocomments/helper.php around lines 111 and 148.
This topic is locked and no more replies can be posted.