RGSerge
10-01-2003, 09:38 AM
I am writing a news page for my website, it collects topics from a news forum and displays them on the homepage.
This works fine, except for one issue. If our news editors use vbcode, it doesnt parse (this is not using a portal and does not include any vb files, its all done via making queries to vb's database).
Question is, how would I be able to parse the vbcode if its entered. This is totally standalone to the vbulletin, and for efficiency reasons I dont want to start integrating with vb core files.
Help here would be greatly appreciated. Heres the function (un-optimised at this time)
global $db_name;
// Get the news articles from the database
$news_array = mysql_query("select * from $db_forum.vb3_thread where forumid = '5' order by threadid DESC LIMIT 15");
if (mysql_num_rows($news_array) > 0)
{
while($news = mysql_fetch_array($news_array))
{
// Assign the data into variables
$article_name = $news['title'];
$article_poster = $news['postusername'];
$poster_id = $news['postuserid'];
$threadid = $news['threadid'];
$comments = $news['replycount'];
$views = $news['views'];
// Sore the language to be used (singular or plural)
$personorpeople = $views == 1 ? 'person' : 'people';
$hasorhave = $views == 1 ? 'has' : 'have';
// Get the article content from the database
$post_array = mysql_query("select * from $db_forum.vb3_post where threadid = '$threadid' order by postid ASC LIMIT 1");
if (mysql_num_rows($post_array) > 0)
{
while($posts = mysql_fetch_array($post_array))
{
$article_body = $posts['pagetext'];
$article_date = $posts['dateline'];
$article_date = getdate($article_date);
$month = $article_date['month'];
$day = $article_date['mday'];
$year = $article_date['year'];
$hour = $article_date['hours'];
$minute = $article_date['minutes'];
$article_date = "$month $day, $year";
$article_body = nl2br($article_body);
$content.=<<<end_cont
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td bgcolor="#828282">
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tr bgcolor="#3A3A3A"><td class="table_heading"><b>$article_date - $article_name</b></td></tr>
<tr bgcolor="#525252">
<td class="table_content">
$article_body
<br /><br />
<hr>
There $hasorhave been $comments comments to this article<br />
$views $personorpeople have viewed the complete article<br />
<a href="http://forums.rgamers.com/showthread.php?t=$threadid">Click Here to view the complete article</a>
</td>
</tr>
</table>
</td></tr></table>
end_cont;
}
}
}
}
return $content;
Thats how it does it, but I need to add the ability to parse smileys and vbcode etc. Anyone know how?
* Smileys is not top priority, vbcode however is.
Thanks for any help on this one.
This works fine, except for one issue. If our news editors use vbcode, it doesnt parse (this is not using a portal and does not include any vb files, its all done via making queries to vb's database).
Question is, how would I be able to parse the vbcode if its entered. This is totally standalone to the vbulletin, and for efficiency reasons I dont want to start integrating with vb core files.
Help here would be greatly appreciated. Heres the function (un-optimised at this time)
global $db_name;
// Get the news articles from the database
$news_array = mysql_query("select * from $db_forum.vb3_thread where forumid = '5' order by threadid DESC LIMIT 15");
if (mysql_num_rows($news_array) > 0)
{
while($news = mysql_fetch_array($news_array))
{
// Assign the data into variables
$article_name = $news['title'];
$article_poster = $news['postusername'];
$poster_id = $news['postuserid'];
$threadid = $news['threadid'];
$comments = $news['replycount'];
$views = $news['views'];
// Sore the language to be used (singular or plural)
$personorpeople = $views == 1 ? 'person' : 'people';
$hasorhave = $views == 1 ? 'has' : 'have';
// Get the article content from the database
$post_array = mysql_query("select * from $db_forum.vb3_post where threadid = '$threadid' order by postid ASC LIMIT 1");
if (mysql_num_rows($post_array) > 0)
{
while($posts = mysql_fetch_array($post_array))
{
$article_body = $posts['pagetext'];
$article_date = $posts['dateline'];
$article_date = getdate($article_date);
$month = $article_date['month'];
$day = $article_date['mday'];
$year = $article_date['year'];
$hour = $article_date['hours'];
$minute = $article_date['minutes'];
$article_date = "$month $day, $year";
$article_body = nl2br($article_body);
$content.=<<<end_cont
<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td bgcolor="#828282">
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tr bgcolor="#3A3A3A"><td class="table_heading"><b>$article_date - $article_name</b></td></tr>
<tr bgcolor="#525252">
<td class="table_content">
$article_body
<br /><br />
<hr>
There $hasorhave been $comments comments to this article<br />
$views $personorpeople have viewed the complete article<br />
<a href="http://forums.rgamers.com/showthread.php?t=$threadid">Click Here to view the complete article</a>
</td>
</tr>
</table>
</td></tr></table>
end_cont;
}
}
}
}
return $content;
Thats how it does it, but I need to add the ability to parse smileys and vbcode etc. Anyone know how?
* Smileys is not top priority, vbcode however is.
Thanks for any help on this one.