View Full Version : BBCodes get converted except for QUOTE and CODE - Why? Please help!
NeilFawcett
07-19-2006, 06:43 AM
I'm trying to use a plugin which allows (amongst other things) to treat a forum as a "new forum". The plugin then simply allows the posts to be listed as "news".
HOWEVER, if the posts use any QUOTE or CODE tags, the text within these tags is completely lost and does not get returned from the code.
IMG tags etc are processed fine for example, just not QUOTE or CODE ones. So I'm a little baffled as to why no text is returned at all for these tags (even if wasn't correctly formatted).
Is anyone able to shed any light on the reason why the text (on these tags) might being going AWOL? Not being able to use QUOTE is a big loss!
The thread about the plugin is [url]https://vborg.vbsupport.ru/showthread.php?t=83005[url] - I posted this very question there (along with others) but no reply/help has been forthcoming :(
louis_chypher
07-19-2006, 10:40 AM
look in yourforum/includes/class_bbcode.php around line 126 and around line 141 for information on how those two bbcode tags work.
NeilFawcett
07-19-2006, 11:18 AM
look in yourforum/includes/class_bbcode.php around line 126 and around line 141 for information on how those two bbcode tags work.
OK... Looks like were onto similar things...
A call to that function (vB_BBCodeParser) already exists.... Is it maybe simply not calling it correctly for the post's text to deal with QUOTE and CODE tags?
Can you see it being used to process the text into "post"?
function output_News($a = 5,$f = ""){
global $db, $Data, $vbulletin;
// Define amount to show
$Amount = ($a)? intval($a) : 5;
// Define Forum To Pull From
$Forum = ($f)? intval($f): '';
if(!$Forum){
RunError("No specified forum to pull news from.");
}
// Load Template
$Template = LoadTemplate("news.html");
// Collect Data
$NewestNews = $db->query("
select t.*,p.pagetext
from ".TABLE_PREFIX."thread t
left join ".TABLE_PREFIX."post p on(p.postid=t.firstpostid)
where t.forumid = $Forum
order by dateline desc
limit 0,$Amount");
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while($News = $db->fetch_array($NewestNews)){
$neils_date = date( "l j", $News['dateline']) . "-" . substr(date( "F", $News['dateline']),0,3) . "-" . date( "Y", $News['dateline']);
$Data .= ParseTemplate($Template,
array(
'threadid' => $News['threadid'],
'threadname' => $News['title'],
'postuserid' => $News['postuserid'],
'postusername' => $News['postusername'],
'post' => $bbcode_parser->parse(unhtmlspecialchars($News['pagetext']), $f),
'comments' => vb_number_format($News['replycount']),
'postdate' => $neils_date,
)
);
}
I believe $f (second parameter) being used in the call is the forum number? That's a bit odd isn't it?
Also in other examples I've seen do_parse is referenced, not "parse"?
Note: Other tags are being converted (eg: IMG and URL)
NeilFawcett
07-20-2006, 06:16 PM
If I do:-
$neils_text = $bbcode_parser->do_parse($News['pagetext'], 0, true, false, true, true, 0);
No BBCode is transformed!
And if I do:-
$neils_text = $bbcode_parser->do_parse($News['pagetext'], 0, true, true, true, true, 0);
All BBCode is transformed except for QUOTE and CODE... What is so special about QUOTE and CODE?
HELP!!!! :(
dc3dreamer
01-04-2009, 01:36 AM
Years later, I am having the same problem, exactly! I'm working on Cyrcix's Email Integration.
$html = $parser->do_parse($bbcode, true, true, true, true, true, 0);
Both [code] and [quote] blocks result in nothing in the HTML output. I have traced it through class_bbcode.php to the point where it fetches the conversion templates for bbCodes. Using a tracing file and fwrite() statements, I have determined that in the function handle_bbcode_code(), the call to fetch_template('bbcode_code') is returning nothing!
Here's the corker: Out of the 20+ tests I did, one time it worked! I then ran the test again without changing anything at all and it failed as before. Throughout, I didn't change anything in the code except to add fopen(), fwrite(), and fclose() to do the tracing (I'm working on a remotely hosted system, ugh).
The difference is that this code is running as a vBulletin Scheduled Task (cron). The same code in another area of the plugin that runs in the normal VB posting context works reliably.
Can anyone give me a hint? The fact that it works once in a blue moon and fails otherwise, with no code changes, has me baffled.
dc3dreamer
01-06-2009, 09:04 AM
This is a crazy problem. I "solved" it by hand-converting the quote and code blocks with preg_replace(). I believe the template cache needs to be loaded in the cron task explicitly. The reason it worked once in a blue moon is that it just happened to run while a forum page was being rendered for some user and the template cache happened to have stuff in it. That's just a theory though!
Marco van Herwaarden
01-06-2009, 09:44 AM
When ran from the Scheduled Task, you must ensure that al needed template groups have been loaded.
That it might work once and not again might be caused by the cache. Either (temporary) disable the post cache or clear the cache table.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.