Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2022, 12:58 PM
Mot235 Mot235 is offline
 
Join Date: Aug 2020
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Count number of search results

Hi is there a way for me to be about to count the number of search results returned from a searchJSON to pass into a variable that I can display to users.

I'm trying to do this as a way to display post counts each user has in a specific topic and this is where I am stuck.

Any help would be amazing.

Code:
<a href="{vb:url 'search'}?searchJSON=%7B%22author%22:%22{vb:raw conversation.authorname}%22,%22exactname%22:%221%22,%22channel%22:[{vb:raw conversation.nodeid}]%7D">[ISO {vb:raw conversation.authorname}]</a>
<vb:else />
<a href="{vb:url 'search'}?searchJSON=%7B%22author%22:%22{vb:raw conversation.authorname}%22,%22exactname%22:%221%22,%22channel%22:[{vb:raw conversation.parentid}]%7D">[ISO {vb:raw conversation.authorname}]</a>
</vb:if>
So far I have been able to generate the search to pull every post a user has in a specific topic in this snippet.
Reply With Quote
  #2  
Old 03-13-2022, 04:39 PM
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Location: USA
Posts: 647
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im not good with json, or vb4 for that matter, but I literally JUST finished making a product that one of the features is grabbing the count of post a user has made in a thread. So if its of any help, or gets you in the right direction take a look at this product for vb4 that is able to pull post count of a user in a thread (its what i just used as my vb3 base). hopefully it will help.

https://vborg.vbsupport.ru/showthread.php?t=285293
Reply With Quote
  #3  
Old 03-13-2022, 04:51 PM
Mot235 Mot235 is offline
 
Join Date: Aug 2020
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, unfortunatly with vb5 they got rid of some of the critical pieces that made the old way this was done. One of them being in the admincp/misc.php as well as changing what a "thread" is and restructuring the forum so that its easier to store in the database without bogging it down.

https://vbulletin.org/forum/showthread.php?t=328571

Thats why I'm trying to find different ways to go about solving this. I appreciate the quick response tho.

--------------- Added [DATE]1647223560[/DATE] at [TIME]1647223560[/TIME] ---------------

Owell you have inspired me tho I do need to get out of my comfort zone and try another strategy and get into building something more significant.

Code:
{class TalonThreadPostCount_dB_MYSQL_QueryDefs extends vB_dB_QueryDefs
{

	protected $db_type = 'MYSQL';
	protected static $permission_string = false;	
	protected $query_data = array
	(
		'getUserThreadPostCount' => array(
			vB_dB_Query::QUERYTYPE_KEY => vB_dB_Query::QUERY_SELECT,
            'query_string' => "
              SELECT COUNT from {TABLE_PREFIX}node 
				Where userid = {userid} AND parentid = {parentid}
			  "
		),

		);
    
}
This should do the same thing essentially just gotta build off it
Reply With Quote
  #4  
Old 03-14-2022, 08:08 AM
delicjous's Avatar
delicjous delicjous is offline
 
Join Date: Nov 2014
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would do that directly in a new template and do a search via the API search, getInitialResults.
Then you get an array containing all the required values. Also the number of posts.

Just look at the templates for an example:
widget_blognodes
widget_search_results

..and use debugvardump to get dump of the array.

Edit: Your query is not taking care of any permission or closed status. The search will ...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03552 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete