Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2007, 01:38 PM
Calash's Avatar
Calash Calash is offline
 
Join Date: Jun 2006
Location: East Coast, USA
Posts: 297
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-19-2007, 01:47 PM
nexialys
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #3  
Old 07-19-2007, 01:50 PM
EnIgMa1234 EnIgMa1234 is offline
 
Join Date: Mar 2006
Location: .:: Ireland ::.
Posts: 1,306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 07-19-2007, 02:03 PM
Calash's Avatar
Calash Calash is offline
 
Join Date: Jun 2006
Location: East Coast, USA
Posts: 297
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 07-19-2007, 02:23 PM
EnIgMa1234 EnIgMa1234 is offline
 
Join Date: Mar 2006
Location: .:: Ireland ::.
Posts: 1,306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Turn on debug mode . Then you can add settings easily
Reply With Quote
  #6  
Old 07-19-2007, 02:34 PM
nexialys
Guest
 
Posts: n/a
Default

sure i suggest to read the source files... they are all built the same way, so you learn quickly
Reply With Quote
  #7  
Old 07-19-2007, 02:44 PM
EnIgMa1234 EnIgMa1234 is offline
 
Join Date: Mar 2006
Location: .:: Ireland ::.
Posts: 1,306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I agree with nexialys. Reading the source files is one of the best ways to learn. Many coders use that method
Reply With Quote
  #8  
Old 07-19-2007, 02:46 PM
Guest190829
Guest
 
Posts: n/a
Default

vBulletin has their Coding Standards available in the documentation:

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

This could help you out a bit.
Reply With Quote
  #9  
Old 07-19-2007, 02:53 PM
nexialys
Guest
 
Posts: n/a
Default

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)
Reply With Quote
  #10  
Old 07-20-2007, 12:08 PM
Calash's Avatar
Calash Calash is offline
 
Join Date: Jun 2006
Location: East Coast, USA
Posts: 297
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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 11:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10822 seconds
  • Memory Usage 2,248KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (6)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete