vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   VBCode outside of vbulletin (https://vborg.vbsupport.ru/showthread.php?t=57529)

RGSerge 10-01-2003 09:38 AM

VBCode outside of vbulletin
 
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)
PHP Code:

 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 == 'person' 'people';
      
$hasorhave $views == '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.

Xenon 10-01-2003 05:09 PM

well, you ahve to require global.php of vb and then use bbcodeparse2 function.

RGSerge 10-01-2003 06:14 PM

Is that function portable, as in, could I life it from global.php and copy it into the main site source and it work (with slight code modification of the function for obvious reasons) i.e. variables and the likes, or would that be a complete pain?

assassingod 10-01-2003 06:24 PM

The code looks like it's for vB3 :confused:
(Technically vB3 hacking isn't allowed, but since this isn't edited any vB3 files, i'll go ahead and post it)

Use this code in your while loop

PHP Code:

$article_bodyparse_bbcode($posts['pagetext']); 

But if it's for vB2, use:
PHP Code:

  $article_body=censortext(bbcodeparse($posts[pagetext],0,1)); 


Xenon 10-02-2003 11:03 PM

Quote:

Originally Posted by RGSerge
Is that function portable, as in, could I life it from global.php and copy it into the main site source and it work (with slight code modification of the function for obvious reasons) i.e. variables and the likes, or would that be a complete pain?

well, as the bbcode is stored into the database, and bbcodeparse2 also uses some vb variables, it would be really hard to make it stand alone.

of course it would be possible, but it would be much easier to require global.php :)


All times are GMT. The time now is 09:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01089 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete