The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
EQDKP in the postbit
I am trying to add a field in the postbit to display the users current DKP. I am somewhat of a novice but I have been learning rather quickly. The way my site is set up is that the EQDKP site and the vBulletin forums are separate MYSQL databases.
The way I envision this working is that I create a new User Profile Field through the Admin CP. It is just a string. My users enter their userid from our DKP site into that field. With this string entered into the 'fieldXX' (field6 for my board), I can use that string to index my array and extract the pertinent data to calculate the current DKP. The code below works properly by itself but I don't have enough knowledge to incorporate it into vBulletin. I'm not sure if this is too much of a bother to even worry about or if it would take just a few lines in the right place - any help would be greatly appreciated. Code:
<?php mysql_connect("myserver.net","myusername","mypassword") or die(mysql_error()); mysql_select_db("mydatabase") or die(mysql_error()); // $dkpname is the string that will come from 'fieldXX' which is a user defined profile field to display in the postbit $yourdkpname = mysql_query("SELECT * FROM eqdkp_members WHERE member_name= '$dkpname'") or die(mysql_error()); $data = mysql_fetch_array($yourdkpname); $yourdkp = $data['member_earned'] - $data['member_spent'] + $data['member_adjustment']; // $yourdkp is the current dkp that I want to be displayed in the postbit ?> |
#2
|
||||
|
||||
To test this, just put the code you posted in a plugin that is fired on the global_start hook, then put $yourdkp in your postbit template (or postbit_legacy if that's the one you're using).
But please sanitize your database inputs. Do you know what would happen if someone entered this as their DKP userid? [sql]joeblow'; drop table eqdkp_members; --[/sql] At least do this before your query. PHP Code:
|
#3
|
|||
|
|||
I believe I have done everything you suggested. However, $yourdkp doesn't seem to be displaying. I have tried entering a manual value for $yourdkp and bypassed the database query in the plugin and I still don't get a value displayed.
This is what I entered in the postbit: Code:
<if condition="$post['field6']">Current DKP: $yourdkp<else />Current DKP: N/A</if> |
#4
|
|||
|
|||
I haven't really looked at your code, but this is what I use on my site in the profile of each person, I have a page that has this code:
PHP Code:
HTML Code:
<tr> <td class="alt1" align="left"> <a href="http://www.yoursite.com/eqdkp/viewitem.php?s=&i=$loot[item_id]" target="_blank">$loot[item_name]</a></td> <td class="alt2" align="left"> <a href="http://www.yoursite.com/eqdkp/viewraid.php?s=&r=$loot[raid_id]" target="_blank">$loot[raid_name]</a></td> <td class="alt1" align="left"> $lootdate </td> </tr> |
#5
|
|||
|
|||
That is definitely something I'd like to try and add in the future. I guess my real sticking point right now is how do I make a variable from a plugin to be passed/available for use in the postbit template?
Thanks again. |
#6
|
||||
|
||||
Quote:
Both the hook evaluation and template evaluation have to be in the same scope. If either one is in a function, it's not going to work. If you do this, it'll work: Plugin code: Code:
$GLOBALS['somevar'] = 'Hey'; Code:
Here's my variable: $GLOBALS[somevar] |
#7
|
|||
|
|||
I got it to work properly... thanks for all of the help here!
|
#8
|
||||
|
||||
In mysql you can prepend the table with the database name.
In other words, you can use the vbulletin mysql object, you dont have to make another, and you can join, call, whatever across databases. select db1.table1.field1,db2.table2.field2.... |
#9
|
|||
|
|||
if you are unable to print out the mysql data from eqdkp - this will work:
in plugin: PHP Code:
in template: PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|