News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Un-answeredTopics for SMF 2.0?

Started by Phphelp, August 24, 2013, 08:11:54 PM

Previous topic - Next topic

Phphelp

I seen this mod, but it's out of date..

http://custom.simplemachines.org/mods/index.php?mod=46

Does anyone know of another mod that does the same thing, paid or free?

margarett

Well, I came up with something :P

I did a rough copy of the "Recent" action and just changed it to include an extra "AND" at SQL queries and, therefore, show you unanswered topics.
It's probably not perfect but, in my test forum, it works ;)

So, if you want to give it a try, you can do the following:
* Copy attached "Unanswered.php" to "/Sources"
* Copy attached "Unanswered.template.php" to "/Themes/default"

Edit "/index.php" and find:
'unread' => array('Recent.php', 'UnreadTopics'),
Add before:
'unanswered' => array('Unanswered.php', 'UnansweredTopics'),

Edit "/Themes/default/languages/index.english.php" and add, before the end of the file:
$txt['unanswered_topics'] = 'Unanswered Topics';
$txt['show_unanswered_topics'] = 'Show unanswered topics';

(You can change the text as you wish, of course)

Finally, if you want to have a link in the page header, you can edit "index.template.php" and find:
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';

And replace with:
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>
<li><a href="', $scripturl, '?action=unanswered">', $txt['show_unanswered_topics'], '</a></li>';


You can access your new action with www.domain.com/index.php?action=unwanswered

The way it is made, it will keep the full functionality of "Recent Posts", as you can add boards and categories to the URL (?action=unanswered;boards=1) and just show topics of those boards/cats
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair


Phphelp

Thanks so much, I just added this in..

Now if I can only get a PHP Guru to answer all the un-answered topics..

Phphelp

Know what also would be cool, if it added a time frame for unanswered that match the setting in the admin for XX days of warning  that your replying to an old post.

margarett

Not sure I understand what you meant, sorry...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Biology Forums

I think he meant, if topic exceeds 90 days, for example, don't show the unanswered thread.

Bigguy

This trick actually works very nicely on SMF 2.1 as well. Thanks. :)


margarett

So you want a list of recent, unanswered topics?
That should be possible, I guess. Have to try it, though.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Phphelp

@margarett

Thanks that would be awesome - you should also turn this into an official mod!

margarett

TBH, I never took the time to learn how to create a mod :P

For the time being, I will try to fulfill your needs. Later we can think about that :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

margarett

It's actually quite easy, as all the relevant data is already retrieved with the actual queries ;)

So, please go to Sources/Unanswered.php and find:

// Get all the most recent posts.
$request = $smcFunc['db_query']('', '
SELECT
m.id_msg, m.subject, m.smileys_enabled, m.poster_time, m.body, m.id_topic, t.id_board, b.id_cat,

Add BEFORE:

//What's the limit for showing posts?
$daysToGet = 100; //This parameter should come from ACP. Maybe later :P
$timeLimit = time() - ($daysToGet * 24 * 60 * 60);

Of course, you will set the amount of days you want to get in the variable $daysToGet

Then, find (just some lines below):

WHERE m.id_msg IN ({array_int:message_list})
AND t.num_replies = 0
ORDER BY m.id_msg DESC

REPLACE with:

WHERE m.id_msg IN ({array_int:message_list})
AND t.num_replies = 0
AND m.poster_time > '. $timeLimit .'
ORDER BY m.id_msg DESC


And there you have it, you own "recent unanswered" topics list ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Phphelp

@margarett that's awesome..

Now the only issue I'm having is that it says I have 10 pages of unanswered topics, but with the shortened time-frame I only have 8 pages..

Create an account on my PHPHelp Forum and take a look.

margarett

Ah yes, I think I see why. Will fix that later today ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

margarett

Actually it's not that easy :(
I understand why it happens but I fail to solve it now :(
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair


margarett

I am working on it ;) I am rewriting the function more or less from scratch. Quite a lesson this is :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Phphelp

I tried to fix it myself, but I was un-successful

constructPageIndex($scripturl . '?action=unanswered', $_REQUEST['start'], 100, 10, false);

Trying to figure how to pass in the right value their to set the page numbers properly..

But I can't find an easy way to do it either :(

margarett

It's bigger than that. The issue is the way the data is gathered and the fact that we are adding filters to the queries without update the count that origins the page index.

What I'm trying to do is to rewrite the function to have new queries and less functions than the original "Recent" action. Not sure if it will be better or worse (performance) but we will see :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: