Support Forum

Big problem with "Order Groups and Forums", I have to reorder all the forums every time I add one.

17 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Great. There are two files to make edits to so we will do the more complex one first and get it over with!

So – file is /simple-press/admin/panel-forums/forms/spa-forums-ordering-form.php

Right down the bottom is a function named sp_paint_order_forum() and our first edit is to that. In the middle of the ‘if’ block is a line assigning the $subforums array. You need to add an extra line of code after that so it reads:

$subForums = unserialize($thisForum->children);
$subForums = sp_sort_by_seq($subForums, $allForums);

Then you need to add the following small function at the bottom after the above function:

function sp_sort_by_seq($subForums, $allForums) {
    $order = array();
    foreach ($subForums as $sub) {
        foreach($allForums as $f) {
            if($f->forum_id == $sub) {
                $order[$f->forum_seq] = $sub;
            }
        }
    }
    ksort($order);
    return $order;
}

The other file is /simple-press/forum/content/classes/sp-forum-view-class.php

Find the function named sp_forumview_build_subforums() about two-thirds of the way through the file. Right at the top of the function – after the ‘global’ statement and before the foreach statement simply add the line:

ksort($subs);

And then see how things pan out. I hope this fixes it for you and thank you for a hard push into where to look. It is always nice to finally find what is lurking in the deep!

MB Matthew BuPane
Matthew BuPane
Member

Beautiful, it now works perfectly.

I moved a forum, they stayed sorted. I edited a forum, they stayed sorted. I created a new top level forum, they stayed sorted. I created a new child forum, they stayed sorted.

I think we are good now, it looks like everything is staying put.

I’ll do some work on them today and stress test the changes for you and let you know if I identify any odd behavior but based on this initial test of things, I believe this hotfix corrected the issue.