Area51 @ 4seven.de

Mod Base and Testarea
It is currently 23 Feb 2025, 14:45

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: 15 Oct 2019, 23:56 
Offline
Tiptop
Tiptop
User avatar

Joined: 03 Jul 2011, 15:03
Posts: 17
Html replacement in post text

With this snippet you can use html as a kind of word censor in posts

Requested by: Mike3396
Request topic: http://www.phpbb.com/community/viewtopi ... &t=2157114

Instruction

open

includes/functions_content.php

find

Code:
    $vars = array('text', 'uid', 'bitfield', 'flags');
    extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); 


after add [Fix**]

Code:
    // BNa
    
global $phpbb_root_path$phpEx;
    include(
$phpbb_root_path 'includes/functions_word_censors.' $phpEx); 


load up a file named functions_word_censors.php (utf8 without a bom) with following (test)-content to includes/functions_word_censors.php

Code:
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
    exit;
}


// Here all Word-Censors // Just replace without any masking

$text = @preg_replace('#\bBanana\b#', '<span style="color:red; font-weight: bold;">Banana</span>', $text);
$text = @preg_replace('#\bBanan\b#', '<a href="http://www.google.de">Banan</url>', $text);
$text = @preg_replace('#\Bthinsp\B#', '&thinsp;', $text);

?>


Result for "Banana":
Image

Note

Edit Banana to any word with any html as replacement like <span style="color:red; font-weight: bold;">Banana</span>.

Leave all other syntax in place. Make as many "new lines" you want.

\b is for search > solo words > test (boundarys)
\B is for search > words in words like testthinsptest (not bounded)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
[ Time : 0.010s | 22 Queries | GZIP : Off ]