Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: cddude - kesäkuu 03, 2014, 05:07:33 AP

Otsikko: Get topic views and replies?
Kirjoitti: cddude - kesäkuu 03, 2014, 05:07:33 AP
Hello,

I'm wondering which is the most efficient way to retrieve the number of views and replies of a given topic (from id_topic).
Should i run a query for this or is there a function to do this for me? If yes, which?

Thanks.
Otsikko: Re: Get topic views and replies?
Kirjoitti: margarett - kesäkuu 03, 2014, 05:17:34 AP
It depends on where you are doing it.

Topic info is available when you are in topic context (ie, displaying topic posts or in MessageIndex). If you need it outside that context, you need to grab it from the DB with $smcFunc['db_query']
Otsikko: Re: Get topic views and replies?
Kirjoitti: cddude - kesäkuu 03, 2014, 05:25:47 AP
Ok thanks!