Quote:
Originally Posted by Chris8
Well, I'm familiar with vb in some way, but I'm not a coder. As for modifying I would only like to execute sorting only on demand, not by default. I guess I need to edit showthread template and put there a link that will run the sorting query when user clicks it. To create the query I must add a plugin and place it somewhere within showthread perhaps showthread_start hook or maybe showthread_query_postids hook would be suitable.
But the question is how would look like the code executing this query. I've just thought that perhaps someone has done it before and wouldn't mind to share the code. I think that feature could be very powerful addition to this mod.
|
While there's plugin hooks you can use to setup the option, what you want to do requires an source change to the query -- people hate those which is the only reason why it's not a part of the mod.
Here's the basics of what you need to do:
1. Add a plugin hook for showthread_post_start
along the lines of
Code:
// get the variable to see if the user wants to sort by votes
$vbulletin->input->clean_gpc('r', 'sortvotes', TYPE_STR);
// see if the user opted to sort by the post votes AND voting is enabled in this forum
if($vbulletin->GPC['sortvotes'] AND $forum['helpfulanswerbits']){
$sortquery = "ORDER BY helpfulpost.totalrank DESC";
echo "<!--sort by posts-->";
// either HA is not on or the user doesn't want to sort by it; back to default
} else {
$sortquery = "ORDER BY post.dateline ". $postorder;
echo "<!--sort normally-->";
}
2. In showthread.php
find ORDER BY post.dateline $postorder and
replace it with $sortquery
3. Repeat this for all 3 instances of the original code
4. Add a link to the post with the variable &sortvotes=1 to enable sorting by votes
5. To check that the plugin is getting called view source the page and look for "sort by posts" or "sort normally". You can remove this once the hack works.
Note:
This isn't tested so while it won't destroy any data it may throw an error and may not work if you filter a post another way, click to the next page, etc.