![]() |
subforums - list by last post
Hi,
Im on a project to try and make subforums display in order of last post made, I mean subforums on the 2cd level pages, (forumdiusplay.php) not home page. Reverse engineering is getting time consuming, just thought Id ask if anyone has done this, and /or can point me to areas of code that might be places to touch. Allan |
I think you'd need to plugin to the forumdisplay_start hook and re-order $vbulletin->iforumcache[] according to the lastpost data in the forumcache.
Something like: Code:
function lastpost_sort ($a, $b) { -- hugh --------------- Added [DATE]1201676889[/DATE] at [TIME]1201676889[/TIME] --------------- Well poop. That won't work because cache_ordered_forums(), which builds the iforumcache, is called AFTER forumdisplay_start. There's a hook in cache_ordered_forums itself, but I'm still trying to work out how to use it. I'm needing to do almost exactly the same thing, so I hope I'll find a workaround soon ... -- hugh --------------- Added [DATE]1201712842[/DATE] at [TIME]1201712842[/TIME] --------------- Well, good news for me, bad news for you. I worked out how to do this for my requirement (which uses some fields I added to the forum table, for forum rating). Uses this code on forumdisplay_start, which is very similar to the code I first posted, but sorts the actual forumcache, not the iforumcache. Turns out the iforumcache is simply derived from the ordering of forumcache: Code:
<?php -- hugh --------------- Added [DATE]1201716914[/DATE] at [TIME]1201716914[/TIME] --------------- OK, I finally got this to work. It's one of those chicken and egg problems. The 'lastpost' info is added to the forumcache by cache_ordered_forums(), but the only hook we can use is called before cache_ordered_forums(). So the only solution I can find is to modify the above code, and add a call to cache_ordered_forums() before the uksort(). This works, but adds a query to the forumdisplay page load, because forumdisplay is going to call cache_ordered_forums() again after our hook runs (but this time, it'll build it from our re-ordered forumcache). If you can live with this, then the following code (still on the forumdisplay_start hook) does what you want. Tested in 3.7b3, but should work on 3.6: Code:
<?php -- hugh |
All times are GMT. The time now is 03:51 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|