PDA

View Full Version : [Solved] Added $thread[preview] to forumdisplay, but linebreaks are stripped


Marris
08-11-2006, 10:29 AM
I added $thread[preview] below each thread title in my threadbit template, so the forumdisplay shows a thread preview for all threads without having to mouseover the link.

My problem is that the linebreaks are stripped, so all the paragraphs are stuck together. This doesn't happen with the mouseover preview (when title=$thread[preview]). When I mouseover a link the preview retains the proper linebreaks.

Any suggestions to keep the $thread[preview] linebreaks intact when displaying outside of the link title (mouseover)?

Thanks.


UPDATE:

Well, I got the line breaks to display correctly by adding...

$thread['preview'] = nl2br($thread['preview']);

in functions_forumdisplay.php , but this causes a problem for the mouseover preview formatting.

I am still looking for a better way to do this the retains proper formatting for both mouseover previews and inline previews, preferably without any php code changes.

RS_Jelle
08-11-2006, 12:29 PM
Just add:
$thread['preview2'] = nl2br($thread['preview']);
And use that for your thing and keep the normal preview for the mouseover ;)

Marris
08-11-2006, 03:20 PM
Just add:
$thread['preview2'] = nl2br($thread['preview']);
And use that for your thing and keep the normal preview for the mouseover ;)

Thanks for the suggestion. Is there any other way to get this to work using threadbit template changes only, without editing the function_forumdisplay.php code?

RS_Jelle
08-11-2006, 03:41 PM
Have a look if there's a hook location in the area where you need to do the current edit, then you can use the plugin system ;)

Kirk Y
08-11-2006, 06:14 PM
Threadbit_process would probably work.

Marris
08-12-2006, 08:15 AM
Thanks to both of you! It's now working as a plugin without any file edits.

Here's the threadbit_process plugin code:

if ($ignore["$thread[postuserid]"])
{
$thread['preview2'] = '';
}
else if (isset($thread['preview']) AND $vbulletin->options['threadpreview'] > 0)
{
$thread['preview2'] = nl2br($thread['preview']);
}

Then $thread[preview2] in the threadbit template will display proper line breaks when used for inline thread previews in forumdisplay.php.