Sorting Discussions by Date Created, rather than most recently Updated, EXCEPT in Public Forum?
Hi all,
I'm running 2.1.7, with a hacky sort of plugin that forces the forum to sort discussion posts by order created, rather than order updated. See near the end of this: http://vanillaforums.org/discussion/27892/need-to-sort-discussions-by-date-created-not-most-recent-comment/p2
The reason/need for the plugin is because the config entries that should get the forum to order in a way other than 'most recently commented on' aren't being read/acted on in core, at the moment. This was true when I posted the original question (running 2.1.3) and as near as I can tell, is still true now.
Now, aside from that issue, my users have come to me a further request: they prefer the "keep everything in the order in which it was first posted" for the classroom Categories, but would like the "order by most recently updated" for the Public areas of the forum where everyone's just talking about whatever and chatting.
Pretend, for the sake of argument, there's a single Category I'd like to order by "most recently commented", and the rest I need to keep sorting by "created at"...
Any way to do that?
Comments
Where there is a will, there is a way!
All you need to do is add a check as to what is being requested against your configured category ID and not perform the hacky work around.
Be sure to add the CategoryID to your
/conf/config.php
file with e.g.$Configuration['HackyPlugin']['CategoryID'] = 3;
.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Excellent!
I probably won't be able to implement this until next week, but will report back then.
Hopefully you don't have any issues, because that is untested code.
Because that is how I roll at 4 pm.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Okay, I've added:
Which is the ID for the Public Forum category.
And I have the following in the plugin,
The good news: it didn't break anything. Everything is still ordering by date posted.
The bad news: the added bits don't seem to be doing anything to the display of posts in the public forum. I suspect I'm missing something.
Go ahead and add
var_dump($Sender->EventArguments['Wheres']);
as the first line in your function and visit a page.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Edit: Nevermind, that was poor placement on my part.
It doesn't look like I'm getting any messages kicked out.
Here we go.
Up at the top of the forum page, above the header, I get this:
Please see the image here:
I flipped on debug to see what all was going on with the category in question, and it sure LOOKS like the system knows it's supposed to be doing something different with CategoryID 20.
It just... isn't.
However, a little bit later down, you get this:
Which seems to be the opposite and... since it's coming up later in the debug, is perhaps the thing that runs last? Not sure where that's coming from. :P
Looking further - is it behaving as intended for Announcements and not for 'normal' discussions?
Answer: Yes. In CategoryID 20 Announcements, it's sorting by last comment, but for non-announcements, it's behaving like the rest of the forum and sorting by DateInserted.
However, it looks like Announcements are only 'working' because they've always ignored my hacky little plugin.
Looks like you need to loop through the array of wheres or use in_array: http://php.net/manual/en/function.in-array.php
You can ditch the var dump line.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
That got it, @hgtonight - thanks for your help on this.