TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

June 29, 2024, 04:31:15 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,282
  • Total Topics: 21,227
  • Online today: 59
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 64
  • Total: 64

[BLOCK] Unanswered Topics Block

Started by shengton, September 26, 2008, 09:26:11 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

shengton

Hello guys, good day. :)

I searched awhile ago and I didn't find what I need. I need a block/script that instead of Recent Topics that will be displayed in. I want to change it to Unanswered Topics instead of Recent Topics. I can't see any type of block type. I want to put is in my Homepage right panel. So I think a script can do the job.

I need a script that will display Unanswered Topics.

I'm using SMF software.

Hope you can help me with this. I really really need it.

Thanks and God bless. :)

Ken.

Please read the Posting Guidelines.html
SHENGTON, if you'll follow the posting guidelines and give us the info called for it will be lots easier for our code snippets specialists to help you. :)
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

shengton

Sorry Sir...Thanks for reminding me with the guidelines.

Can I request a script for Unanswered Topics. Please I really need it.

JPDeni

I tried to make it, but couldn't work it out. It should be easy, but my brain doesn't seem to be working. I'll try again later.

JPDeni

Okay. Let's try this again.


global $db_prefix, $scripturl, $user_info;

$number_to_display = 10; // Change this if you want a different number to display. Use 0 to list all of them.
$most_recent_first = 1; // If you want to display the oldest first, change this to 0

//////////////////////////////////////////

($most_recent_first == 1) ? $order = 'DESC' : $order = 'ASC';
($number_to_display == 0) ? $limit = '' : $limit = "LIMIT " . $number_to_display;

$query = db_query(
"SELECT m.subject, t.ID_TOPIC
FROM {$db_prefix}topics as t, {$db_prefix}messages as m, {$db_prefix}boards AS b
WHERE t.numReplies = 0
AND t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = b.ID_BOARD
AND $user_info[query_see_board]
ORDER BY t.ID_FIRST_MSG " . $order . ' ' .
$limit, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
  echo '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">' . $row['subject'] . '</a><br />';


Ianedres

Most excellent! Good work there.

Ooh. Ternary operator... :o

JPDeni

Thanks! The problem I had at first was using $user_info['query_see_board'] incorrectly. I figured if I didn't include it, someone would come along and request it.

QuoteOoh. Ternary operator...

My education is very spotty, so I'm not sure exactly what that means. Are you referring to


($most_recent_first == 1) ? $order = 'DESC' : $order = 'ASC';


I love those! :D I just found out that some programmers think they're bad form. To me, they make logical sense. And they're tidy. I like tidiness. ;)

Ianedres

May I suggest this to not list the deleted posts, but only the valid posts...

global $db_prefix, $scripturl, $user_info, $modSettings;

$number_to_display = 10; // Change this if you want a different number to display. Use 0 to list all of them.
$most_recent_first = 1; // If you want to display the oldest first, change this to 0

if(!empty($modSettings['recycle_enable'])) $recycle_board = $modSettings['recycle_board'];

//////////////////////////////////////////

($most_recent_first == 1) ? $order = 'DESC' : $order = 'ASC';
($number_to_display == 0) ? $limit = '' : $limit = "LIMIT " . $number_to_display;

$query = db_query(
"SELECT m.subject, t.ID_TOPIC
FROM {$db_prefix}topics as t, {$db_prefix}messages as m, {$db_prefix}boards AS b
WHERE t.numReplies = 0
AND t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = b.ID_BOARD
AND $user_info[query_see_board]
AND b.ID_BOARD != $recycle_board
ORDER BY t.ID_FIRST_MSG " . $order . ' ' .
$limit, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
  echo '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">' . $row['subject'] . '</a><br />';

Ianedres

I first came across the ternary (aka trinary) operator while perusing through Bloc's code for TP.

I couldn't make head or tails of what was happening at the time, and it is hard to find an explanation on php.net about it, since it uses "?" as a name.

And whether it is considered proper or not, I like to use it whenever practical.


IchBin

The ternary statement is widely used in many languages. Anyone who says it is sloppy should have their eyes examined. lol