The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
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) { global $vbulletin; if ($vbulletin->forumcache[$a]['lastpost'] == $vbulletin->forumcache[$b]['lastpost']) { return 0; } else { return ($vbulletin->forumcache[$a]['lastpost'] > $vbulletin->forumcache[$b]['lastpost'] ? -1 : 1); } } uksort($vbulletin->iforumcache[$vbulletin->GPC['forumid']], 'lastpost_sort'); -- 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 function forumrate_sort ($a, $b) { global $vbulletin; if ($vbulletin->forumcache[$a]['votetotal'] == $vbulletin->forumcache[$b]['votetotal']) { return 0; } else { return ($vbulletin->forumcache[$a]['votetotal'] < $vbulletin->forumcache[$b]['votetotal'] ? -1 : 1); } } uksort($vbulletin->forumcache, 'forumrate_sort'); ?> -- 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 function forumrate_sort ($a, $b) { global $vbulletin; if ($vbulletin->forumcache[$a]['lastpost'] == $vbulletin->forumcache[$b]['lastpost']) { return 0; } else { return ($vbulletin->forumcache[$a]['lastpost'] > $vbulletin->forumcache[$b]['lastpost'] ? -1 : 1); } } cache_ordered_forums(1, 1); uksort($vbulletin->forumcache, 'forumrate_sort'); ?> -- hugh |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|