The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Count users threads from specific forum ID's
I need insert in member profile page (memberinfo_block_statistics)
MYSQL query (count threads from specific forums ID) What query i should use in hook area ? I search forum with similar problem but i only found this:: Code:
SELECT t.forumid = 1 AND t.forumid = 2 AND t.forumid = 3 FROM thread AS t WHERE t.postuserid = X What should i repleace X with to get stats for every single user ? edit: i found also something like this: PHP Code:
It does not work --------------- Added [DATE]1263885685[/DATE] at [TIME]1263885685[/TIME] --------------- anyone ? |
#2
|
|||
|
|||
bump !
please reply |
#3
|
|||
|
|||
I think something like this works for the query:
Code:
SELECT COUNT(*) AS count FROM thread WHERE postuserid = id AND forumid IN(1, 2) Code:
$count = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."thread WHERE postuserid = $vbulletin->userinfo[userid] AND forumid IN(1, 2, 3)"); Where to put it is another question, it looks like the HTML for those blocks is generated in member.php around line 474, and there's a member_build_blocks_start hook right before that, so maybe that's a good place. |
#4
|
|||
|
|||
Thank you for reply mate !
i think that someting else is wrong in $vbulletin->userinfo[userid] after create new plugin in member profile i can see this error Code:
Database error in vBulletin 3.7.4: Invalid SQL: SELECT COUNT(*) AS count FROM thread WHERE postuserid = Array[userid] AND forumid IN(1, 2, 3); 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 '[userid] AND forumid IN(1, 2, 3)' at line 2 Error Number : 1064 |
#5
|
|||
|
|||
Oh yeah, sorry, try
Code:
$count = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."thread WHERE postuserid = ". $vbulletin->userinfo['userid']." AND forumid IN(1, 2, 3)"); |
#6
|
|||
|
|||
yeah that's better !
now when i try to add in template MEMBERINFO Code:
$count['count'] Code:
The following error occurred when attempting to evaluate this template: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sportforum/domains/sportforum.pl/public_html/includes/adminfunctions_template.php(3772) : eval()'d code on line 8 This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. or maybe in hook area insed of: Quote:
Quote:
|
#7
|
|||
|
|||
Sorry, obviously I didn't try any of this and to be honest I keep forgetting what works in templates. Try $count[count], it should be the same (you might also want to use some variable name other than 'count', it's kind of a common name). There's probably some "right" way to do this without creating a new variable.
I don't think you need to do anything like using ob_start/end. You may need to be using a global, however (I already forgot what the code looked like). I think this may be what template hooks are for, so you don't have to worry about variable name conflicts and globals. Maybe someone who knows more will enlighten us ETA: Meanwhile, maybe try something like: Code:
$vbulletin->userinfo['memberinfo_threadcount'] = $count['count']; Code:
$bbuserinfo[memberinfo_threadcount] |
#8
|
|||
|
|||
i think we're so close but again something is wrong it show always 0
in nut shell what i've done: name: samle_test location: member_build_blocks_start code: Code:
$count = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."thread WHERE postuserid = ". $vbulletin->userinfo['userid']." AND forumid IN(164, 165, 166)"); $vbulletin->userinfo['memberinfo_threadcount'] = $count['count']; Code:
<li><span class="shade">Płatne Artykuły:</span> $bbuserinfo[memberinfo_threadcount]</li> And in member profile i can see Płatne Artykuły: 0 It shoud be 386 not 0 DEMO: http://www.sportforum.pl/members/marcin-hejnowicz.html (Go To Statistic) |
#9
|
|||
|
|||
Well, I guess that means the $bbuserinfo didn't work like I'd guessed. Try this instead: use $template_hook[profile_stats_threadcount] in both places instead of $vbulletin->userinfo['memberinfo_threadcount'] and $bbuserinfo.. etc. And if that doesn't work, add a
global $template_hook; line before you set it in the plugin. |
#10
|
|||
|
|||
I dont understand what's:
Quote:
Plugin: Code:
$count = $vbulletin->db->query_first("SELECT COUNT(*) AS count FROM ".TABLE_PREFIX."thread WHERE postuserid = ". $vbulletin->userinfo['userid']." AND forumid IN(164, 165, 166)"); $template_hook; $template_hook[profile_stats_threadcount] = $count['count']; Code:
<li><span class="shade">Płatne Artykuły:</span> $template_hook[profile_stats_threadcount]</li> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|