The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I'm using a feedback system (itrader) mod which gives all users on my site a feedback score based on successful item purchases, and I would like to include this score in the postbit. However, a certain few lines of code need to be executed in order to fetch the value of the feedback variable from the database.
Which hook location would I use to insert my code, given a separate feedback score needs to be retrieved for each postbit? The variable which my code should populate is included in my postbit_legacy template. |
#2
|
||||
|
||||
![]()
I'd figure out the names of the columns you need and in which table they are in and see if you can use a plugin to do a join into and existing query for the post information. But, as I mentioned, you need the name of the column, the table, and the column to do userid join on.
|
#3
|
|||
|
|||
![]()
Thanks for the reply!
Here's the query that I'd be running: Code:
$itraders = $vbulletin->db->query_read("SELECT COUNT(" . ($vbulletin->options['itrader_ratestyle'] ? 'DISTINCT(userid)' : 'userid') . ") AS usercount, COUNT(*) AS usercountall, rating FROM " . TABLE_PREFIX . "itrader WHERE rateduserid = " . $userinfo['userid'] . " GROUP BY rating "); |
#4
|
||||
|
||||
![]()
That would add one query per post. It's better to add a join to an existing query is what I'm saying.
|
#5
|
|||
|
|||
![]()
Definitely- fifteen extra queries per page of a thread could be pretty hard on the server. Let me know if you can help me out with finding the one query to add my code to, and if you need any additional info. Thanks in advance!
|
#6
|
||||
|
||||
![]()
Look in showthread.php - look where it generates a query for users.
![]() |
#7
|
|||
|
|||
![]()
Looks like that would be around
PHP Code:
Update: After placing that query after showthread_query, I get a DB error: Code:
Database error in vBulletin 3.7.4: Invalid SQL: SELECT COUNT(DISTINCT(userid)) AS usercount, COUNT(*) AS usercountall, rating FROM _vbitrader WHERE rateduserid = GROUP BY rating; MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY rating' at line 4 Error Number : 1064 Request Date : Saturday, January 3rd 2009 @ 01:47:53 AM Error Date : Saturday, January 3rd 2009 @ 01:47:54 AM Classname : vB_Database MySQL Version : 5.0.22 PHP Code:
|
#8
|
||||
|
||||
![]()
Look at the query right under that hook!!! You can use $hook_query_joins...
|
#9
|
||||
|
||||
![]()
I don't think $userinfo is going to work on the showthread page. The variable you want to use there is $post. So, try changing that in your query and see if it works.
But, as Hanson pointed out, you can simply join into the existing $post query to grab your information there with a join to your itrader table. |
#10
|
|||
|
|||
![]()
Your mentioning $post got me to try using those in my postbit, and it turns out both $post[itrader_total] and pcnt are defined. So problem solved! Thanks for your help.
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|