PDA

View Full Version : Thread data manager and line breaks


TiKu
02-10-2013, 04:07 PM
Hi,

I want to use data manager to create a new thread and I want the first post to contain line breaks. But I don't want to make the forum allow HTML, so I cannot use <br>.
Here's my code:

$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = 27;
$userid = 33256;
// $mytitle and $mytext actually come from extern
$title = addslashes($mytitle);
$pagetext = addslashes($mytext);
$url = 'http://www.google.de'; // just a sample
$pagetext .= '\n\nClick here (' . $url . ')';
$allowsmilie = '0';
$visible = '1';

$foruminfo = fetch_foruminfo($forumid);
$threadinfo = array();
$user = htmlspecialchars_uni(fetch_userinfo($userid));

$threaddm->set_info('forum', $foruminfo);
$threaddm->set_info('thread', $threadinfo);
$threaddm->setr('forumid', $forumid);
$threaddm->setr('userid', $userid);
$threaddm->setr('pagetext', $pagetext);
$threaddm->setr('title', $title);
$threaddm->set('allowsmilie', $allowsmilie);
$threaddm->set('visible', $visible);

$threadid = $threaddm->save();

With this code, the created post looks like this:

Bla\n\nClick here (www.google.de)


I want it to look like this:

Bla

Click here (www.google.de)

What am I doing wrong?

Regards
TiKu

kh99
02-10-2013, 04:18 PM
Escape sequences like \n only work in double-quoted strings. So if you change your pagetext line like:
$pagetext .= "\n\nClick here";


it should work.

TiKu
02-10-2013, 04:23 PM
Argh! Many thanks, without your help I would have been searching the error for days.