Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2017, 06:49 AM
Mattwhf Mattwhf is offline
 
Join Date: May 2016
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to Count number of replies from a thread id?

First off, thanks Lynne for this tutorial How to Create your own vBulletin 4 page because I could create my own best web hosting page on our hosting forum, but now I am wanting to enhance it by adding some new functions, for example, show number of reviews from a thread id on my forum to that page.

In my page, I have User comments ? I want to show number of replies from a thread which a web hosting company is having review on their own thread. i.e 6 User comments ?

Is it possible to count number of replies from a thread id?

I mean (on Lynne's tutorial page ) then the code to count that will be putted on test.php and I can push it into a variable to display on my vB template.

Any ideas?

Thanks in advance.
Reply With Quote
  #2  
Old 06-24-2017, 11:01 AM
In Omnibus's Avatar
In Omnibus In Omnibus is offline
 
Join Date: Apr 2010
Location: Inside A Blade Server
Posts: 840
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First of all, that is not a vBulletin4 page. Even clicking on the Forums tab doesn't go to a vBulletin forum. It goes to an ad page, one I'd thank you to stop spamming here.

Secondly, unless users are replying multiple times in the thread, the number of replies is the number of user comments. That is displayed by default unless you've removed it.
Reply With Quote
  #3  
Old 06-24-2017, 01:14 PM
Mattwhf Mattwhf is offline
 
Join Date: May 2016
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by In Omnibus View Post
First of all, that is not a vBulletin4 page.
Why it is not a vBulletin 4 page?

As said, I created it from Lynne's guide.

Quote:
Originally Posted by In Omnibus View Post
Even clicking on the Forums tab doesn't go to a vBulletin forum.
I don't understand your meaning, can you share a screenshot to explain?

Quote:
Originally Posted by In Omnibus View Post
It goes to an ad page, one I'd thank you to stop spamming here.
It is not allowed to show a page like that on this forum?
I only want to explain what I wanted to add to my page, you can visit it but you can not need to click on any links on the page, just have a look.

Quote:
Originally Posted by In Omnibus View Post
Secondly, unless users are replying multiple times in the thread, the number of replies is the number of user comments. That is displayed by default unless you've removed it.
I still don't understand your answer and you seem didn't understand my question.
I mean I want to create a function to query number of replies in a thread (reviews) and showing it on each link on vB page. Just that.

Seem I could find a solution for this by this thread https://vborg.vbsupport.ru/showthread.php?t=41235

but still needing better solutions if possible.

Thanks
Reply With Quote
  #4  
Old 06-24-2017, 01:20 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Suppose you have the threadid stored in the variable $threadid...then you can get an array containing information on the specified thread, using something like:

PHP Code:
$threadinfo fetch_threadinfo($threadid); 
And then to get the number of replies for that thread, you could use:

PHP Code:
$replies $threadinfo['replycount']; 
Reply With Quote
  #5  
Old 06-24-2017, 01:30 PM
Mattwhf Mattwhf is offline
 
Join Date: May 2016
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
Suppose you have the threadid stored in the variable $threadid...then you can get an array containing information on the specified thread, using something like:

PHP Code:
$threadinfo fetch_threadinfo($threadid); 
And then to get the number of replies for that thread, you could use:

PHP Code:
$replies $threadinfo['replycount']; 
No, I think this will not show number of replies on my page because it is not a thread.

I am needing a query to show number of replies from 10 threads (for 10 hosting companies that I am listing on my page)

for example:

$id4895 = count_replies(4895);
$id7894 = count_replies(7894);
$id674 = count_replies(674);
$id4563 = count_replies(4563);
...

count_replies function will is a function that contained queries depends on thread id.
and on test.php I will assign these

$templater->register('id4895 ', $id4895 );
$templater->register('id7894 ', $id7894 );
$templater->register('id674 ', $id674);
....

After that I can show

{vb:raw id4895}

{vb:raw id4895}

{vb:raw id674}

on my template and they will show number of replies for each thread id.

The problem that I am caring is queries to get number of replies on each thread can make my forum or that page loads slowly or not.

Thanks
Reply With Quote
  #6  
Old 06-24-2017, 01:35 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mattwhf View Post
No, I think this will not show number of replies on my page because it is not a thread...
When the title of the thread refers to a thread id, then I assume you are talking about a thread.
Reply With Quote
  #7  
Old 06-24-2017, 01:39 PM
Mattwhf Mattwhf is offline
 
Join Date: May 2016
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
When the title of the thread refers to a thread id, then I assume you are talking about a thread.
Yes but some people can ignore this or didn't read it carefully

Quote:
Originally Posted by Mattwhf View Post
First off, thanks Lynne for this tutorial How to Create your own vBulletin 4 page because I could create my own best web hosting page on our hosting forum, but now I am wanting to enhance it by adding some new functions, for example, show number of reviews from a thread id on my forum to that page.
Mean I need to show number of replies from a thread id on my forum but on my page that I created.

Of course is number of reviews = replies.
Reply With Quote
  #8  
Old 06-24-2017, 01:44 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mattwhf View Post
Yes but some people can ignore this or didn't read it carefully



Mean I need to show number of replies from a thread id on my forum but on my page that I created.

Of course is number of reviews = replies.
If you are trying to get the number of replies for a single thread, then using what I initially posted will work fine. However, if you are trying to get the number of replies for an array of threads, then using a custom query would be more efficient.

I would create an array to store the respective replycounts, where the keys are the thread ids and then simply pass this array to the template.
Reply With Quote
Благодарность от:
Mattwhf
  #9  
Old 06-24-2017, 01:52 PM
Mattwhf Mattwhf is offline
 
Join Date: May 2016
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
I would create an array to store the respective replycounts, where the keys are the thread ids and then simply pass this array to the template.
Would you mind sharing details/codes for this way?

I can solve this but it can not be a professional way thus that's why I ask this question here.

Thanks
Reply With Quote
  #10  
Old 06-24-2017, 02:07 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mattwhf View Post
Would you mind sharing details/codes for this way?

I can solve this but it can not be a professional way thus that's why I ask this question here.

Thanks
Okay, I would do something like this:

PHP Code:
$replycounts = array();

// Edit the following line to contain all threadids you wish to include.
$threadids '674,4563,4895,7894';

$threads$vbulletin->db->query_read("SELECT thread.*
    FROM " 
TABLE_PREFIX "thread AS thread
    WHERE threadid IN (" 
$threadids ")
"
);

while (
$thread $db->fetch_array($threads))
{
    
$replycounts[$thread['threadid']] = $thread['replycount'];

Now you can pass the $replycounts array to your template, and then display them from your template with:

{vb:raw replycounts.674}
{vb:raw replycounts.4563}
{vb:raw replycounts.4895}
{vb:raw replycounts.7894}

etc.

Does this make sense?
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 06:35 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.04570 seconds
  • Memory Usage 2,287KB
  • 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
  • (5)bbcode_php
  • (11)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete