Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
VBCode outside of vbulletin Details »»
VBCode outside of vbulletin
Version: , by RGSerge RGSerge is offline
Developer Last Online: Dec 2006 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 10-01-2003 Last Update: Never Installs: 0
 
No support by the author.

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.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 10-01-2003, 05:09 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, you ahve to require global.php of vb and then use bbcodeparse2 function.
Reply With Quote
  #3  
Old 10-01-2003, 06:14 PM
RGSerge's Avatar
RGSerge RGSerge is offline
 
Join Date: Feb 2003
Location: United Kingdom
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #4  
Old 10-01-2003, 06:24 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The code looks like it's for vB3
(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)); 
Reply With Quote
  #5  
Old 10-02-2003, 11:03 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:35 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.03982 seconds
  • Memory Usage 2,264KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (4)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete