vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   VB Plugins - Good Coding practices (https://vborg.vbsupport.ru/showthread.php?t=152751)

Calash 07-19-2007 01:38 PM

VB Plugins - Good Coding practices
 
Is there any good resource for the best practices when writing plugins?

I have written a few for my personal site so far, however I would like to get into the practice of using the available VB functions when doing this.

For example, here is a snip of code

Code:

$content = "";

$query = "SELECT title, sid, summary, username, rid, unix_timestamp(updated) from fanfiction_stories as s,vb_user as a WHERE a.userid = s.uid AND s.validated > 0 AND s.uid = $userinfo[userid] ORDER BY updated DESC";
$results = mysql_query($query)  or die(_FATALERROR."Query: ".$query."<br />Error: (".mysql_errno( ).")");

while($story = mysql_fetch_array($results)) {
    $content .="$story[title] By $story[username]<br />";
}

if ($content<>"")
{
$efic_mystory = $content;
} else {
$efic_mystory = "No Stories";
}

Now, I know there is probably a better way to do the DB call using vB functions.

Just small stuff like that....if there is a good reference around somewhere it would save me a lot of questions here :)

Thanks

nexialys 07-19-2007 01:47 PM

1- ... it is $results = $db->query_read("writethequeryhere,not seperate!");

2- no need of the "$content<>""" is the $content is not an array... !empty($content) or simply $content would do in the if-condition...

also, for a good way to code vBulletin, simply read vBulletin core files and comprehend the rules of their protocol.. it is clear.

EnIgMa1234 07-19-2007 01:50 PM

Check out the articles section. Some of your code could be better.

Eg.
Code:

$query = "SELECT title, sid, summary, username, rid, unix_timestamp.......
Should be more like this
PHP Code:

$query $vbulletin->db->query_read("SELECT................"); 


while($story = mysql_fetch_array($results)) {

More like
while ($story = $vbulletin->db->fetch_array($results)) {
Things like that

Calash 07-19-2007 02:03 PM

I had been browsing the article section for a bit, but I was looking in the wrong area. Found this one that explains using $vbulletin->db

https://vborg.vbsupport.ru/showthread.php?t=119350

I can spend an hour looking...but as soon as I post the question I will stumble on the answer in 5 minutes :)

Do you mean reading the source files when you say "simply read vBulletin core files"? I would rather not be digging deep into the php files for what are probably simple questions and answers if possible.

Thanks for the feedback..now that I know where to look in the article section I will start reading up...need to learn how to add admin options and settings :)

EnIgMa1234 07-19-2007 02:23 PM

Turn on debug mode :). Then you can add settings easily

nexialys 07-19-2007 02:34 PM

sure i suggest to read the source files... they are all built the same way, so you learn quickly

EnIgMa1234 07-19-2007 02:44 PM

I agree with nexialys. Reading the source files is one of the best ways to learn. Many coders use that method

Guest190829 07-19-2007 02:46 PM

vBulletin has their Coding Standards available in the documentation:

http://www.vbulletin.com/docs/html/codestandards

This could help you out a bit. :)

nexialys 07-19-2007 02:53 PM

damn, i hope you will crawl across your entire script before releasing 4.0, because a lot of these standards are not applied to the actual version.. lol (like it always had)

Calash 07-20-2007 12:08 PM

Thanks for the great feedback. My goal is to expand the eFiction bridge I threw together into a much tighter integration, and if I am going to do that I want to do it right :)

Working on setting up a test server for development on VMWare, that way I wont thrash my site while trying to do this ;)

King Kovifor 07-20-2007 10:16 PM

IF you want to find vBulletin functions, use the API found at: http://members.vbulletin.com/api/


All times are GMT. The time now is 08:08 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.00994 seconds
  • Memory Usage 1,733KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)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