PDA

View Full Version : Replace char in thread title (class_dm_threadpost)


charlie71
06-04-2009, 05:11 PM
Hi,
i want to replace single characters from thread titles in specific forums only.

i've added a small piece of code


function verify_title(&$title)
{
// replace html-encoded spaces with actual spaces
$title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);
if($foruminfo['forumid'] == '31' or $foruminfo['forumid'] == '114' or $foruminfo['forumid'] == '32') {
$title = preg_replace('/[\.]/', ' ', $title);
$title = preg_replace('/[\-]/', ' - ', $title);
$title = str_replace(" ", " ", $title);
}

$title = trim($title);


in class_dm_thread_post.php (line 111), but it seems that $foruminfo is empty.
how to get the forumid in class_dm_thread_post? Any idea?

cheers

Dismounted
06-05-2009, 05:34 AM
The forumid would be contained in:
$this->info['forum']['forumid']

Fluke667
10-25-2012, 03:19 AM
I need do same

How this work exactly? Can any1 Help me?

I want remove - and _ on specific forums...

kh99
10-27-2012, 09:47 PM
The OP has edited the file class_dm_threadpost.php and inserted the code in bold into the function verify_title() where shown (it still looks like it's around line 110). But you also need to use $this->info['forum']['forumid'] instead of $foruminfo['forumid'], so maybe like this:

function verify_title(&$title)
{
// replace html-encoded spaces with actual spaces
$title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);

if (in_array($this->info['forum']['forumid'], 1, 2, 3)) {
$title = preg_replace('/[\.]/', ' ', $title);
$title = preg_replace('/[\-]/', ' - ', $title);
$title = str_replace(" ", " ", $title);
}

$title = trim($title);


Of course you'd replace 1, 2, 3 with the list of one or more forum ids where you want those characters removed.