The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Where to include a new variable?
I have built an SQL query that returns the count of a user's topics in certain forums. I want to use this as a variable, so I can use it in my postbit templates.
The problem is I don't know how to do that. The code I THINK I should use to define the variable with this SQL query is this; $stories = $db->query_first(" SELECT Count(vbthread.threadid) FROM vbthread WHERE (vbthread.forumid = '57' OR vbthread.forumid = '58' OR vbthread.forumid = '59' OR vbthread.forumid = '60' OR vbthread.forumid = '61' OR vbthread.forumid = '62' OR vbthread.forumid = '63' ) AND vbthread.postuserid = '$post[userid]' "); 1. Is this correct? 2. Where should I use this code to define the variable and then be able to use the $stories variable inside my postbit templates? |
#2
|
|||
|
|||
Can anyone please help on this ?
|
#3
|
|||
|
|||
Ok I'm coming back on this, since I solved it - but partially;
I have created a plugin with this code; PHP Code:
But now I cannot use my external RSS forum feeds, I get a database error, saying that: PHP Code:
I think this is because of the HOOK location I've put my plugin in. I put it in postbit_display_start. Is this correct? Should I choose another hook location? |
#4
|
|||
|
|||
Have you tried $post['postuserid'] instead of just $post['userid'] maybe that will correct it?
Also you can just say this for your query: [sql] SELECT COUNT(threadid) AS num FROM vbthread WHERE forumid IN (57, 58, 59..., 63) AND postuserid = $post['postuserid'][/sql] Finally remember you are running a query on every postbit on every showthread so you may want to rethink what you are doing. You may be able to modify the showthread query using the showthread_query hook and add a join/count to the query. |
#5
|
|||
|
|||
Quote:
. |
#6
|
|||
|
|||
Thankyou so much for your reply.
Quote:
Quote:
Quote:
Anyway my website is not that big so I don't have performance issues with this hack, so even if I could correct this problem with my RSS feeds I would keep it in the postbit. Any other ideas? Thankyou for your time. Regards. --------------- Added [DATE]1199918887[/DATE] at [TIME]1199918887[/TIME] --------------- Ok someone else helped me, the solution is here: http://www.vbnova.com/showthread.php?p=7259#post7259 Thanks for taking the time to read this. |
#7
|
|||
|
|||
Ok I'm re-surfacing this thread because I need some help.
I have created a plugin in the Postbit_display_start hook with this code; PHP Code:
The thing is, I want to display the same information in the MEMBERINFO page, anyone know how to do that? I suppose I have to add the variable to another hook as well? |
#8
|
||||
|
||||
I believe the hook for the member profiles would be member_complete
|
#9
|
|||
|
|||
By the way, you can shorten your SQL command by using the [minicode]WHERE forumid IN (57, 58, ...63)[/minicode]
Even though the other bit in my previous post may not have worked, the SQL I posted on the line above will. |
#10
|
|||
|
|||
Thanks fellows for your help.
GameWizard, I tried copying the plugin and using it to the member_complete hook and didn't work. I also tried using the member_start hook, but again no go. I think I also have to change the last part of the code where it says Quote:
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|