PDA

View Full Version : How do I make a vbulletin plugin ?


nascimbeni
13 Aug 2007, 19:34
How do I 'make' a plug in ?
Sorry I did not grasp how vbulletin works yet.
On the top of my forum ( next to the logo ) at http://my.lifeinitaly.com
I want to add a piece of php code that selects 4 / 5 random images. I hove the code and it works : you can see the images here
http://my.lifeinitaly.com/images.php ( the code is below ) - I need then to add something to the header template but what and how ?
I could not find any instruction on how to built a plugin

<?php
$host = 'localhost';
$dbUser = '';
$dbPass = '';
$db = 'photopost';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());
$result = mysql_query("SELECT id,cat,bigimage,width,height FROM pp_photos WHERE storecat = '0' and width > height ORDER BY rand() LIMIT 6" ) or die(mysql_error());
$imgs1='';
while($row = mysql_fetch_array( $result )) {
$imgs1 = $imgs1 . "<a href=\"/photopost/showphoto.php?photo=" . $row['id'] . "\"><img width=105 height=75 src=\"/photopost/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\" border=\"0\"></a>";

}
print $imgs1;
?>

Eikinskjaldi
13 Aug 2007, 22:38
How to make a plugin instructions can be found on this board. Do a bit of searching. Really, you just did the equivalent of logging onto a php site and asking "how do I code in php?"

Here is a couple of pointers...

If you import global.php into your script you have access to the $vbulletin object, including the $vbulletin->db object which is already connected to your database and comes with a bunch of helper functions

vbulletin uses a template system, which means it separates php and html. It is rare you concatenate some html and print it, much more likely you eval template.

Do some research, ask a specific question.