News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Retrieve number of replies to a post?

Started by SulevFan, May 08, 2021, 08:06:35 AM

Previous topic - Next topic

SulevFan

I've looked and can't find this.

Is there a way that given a topic number, I can ask SMF for how many  replies that topic has?

We use the SMF SSi for a few other things, eg, authentication for our wiki, but it does not seem to provide this function.

Steve

Couldn't you just append the topic number onto your forum's url?

e.g. https://www.simplemachines.org/community/index.php?topic=577638.0

That would take you to this topic and show the number of replies. A couple of extra clicks but I don't know of an easier way. Maybe someone else on the team does.
DO NOT pm me for support!

Shambles

You just need to query the {smf}_topics table for id_topic=topic and extract the num_replies value.


<?php
$wanted_topic
=57667;   // <== 

$req=$smcFunc['db_query']('',
   
'select num_replies from smf_topics where id_topic = {int:topic}',
   array(
'topic' => $wanted_topic));

$row $smcFunc['db_fetch_assoc']($req);

$number $row['num_replies'];

SulevFan

Quote from: Shambles on May 08, 2021, 03:54:27 PM
You just need to query the {smf}_topics table for id_topic=topic and extract the num_replies value.


TYVM, much appreciated.

Advertisement: