Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Big problem with "Order Groups and Forums", I have to reorder all the forums every time I add one.
Avatar
Matthew BuPane
Member
sp_UserOfflineSmall Offline
Jul 8, 2015 - 9:31 pm

Hmm, interesting.

Of course I didn't figure this would be an easy to solve problem given the nature of it.

When I used this plugin in the past I never had a problem, so this took me by surprise.

From what I can tell, it looks like it is reordering them based off the "Child" order in the database column. Not sure if that says anything or not, but based on what I see in the tables, that seems to be what it is re-sorting on when a new forum is created.

I guess I'll try re-uploading the PHP files for the plugin and see if that works. I don't know if that will change anything but it can't hurt anything at this point.

I'll try uploading the PHP files and see if that changes anything. I don't know if the information provided above helps narrow anything down, but that appears to be what it is doing.

Avatar
Matthew BuPane
Member
sp_UserOfflineSmall Offline
Jul 8, 2015 - 9:41 pm

Nope, re-uploading the source files didn't seem to change anything. I even completely shutdown Apache, MySQL and rebooted the server before trying to make sure cache was purged and everything else.

 

-- Update --

OK, I know what it is doing, I don't know why, or how to fix it.

I re-ordered my forums the way I wanted them, then pulled them up on the actual site to make sure they were in the order I wanted, they were. I did a SELECT on the wp_sfforums table and sorted on group_id and forum_seq. I got the expected result, the query returned everything in the order I see it on the page itself.

I looked over at the "children" column and everything is written out in the order it needs to be as well. I added another forum and everything reverted back to the unsorted order, and the "children" column now matches the unsorted order. (Even though the "forum_seq" is STILL correct, and it doesn't update the "forum_seq" until I use the tool to re-sort and re-order the forums)

I manually updated the "children" column and swapped two of the forums I was having issues with. When I refreshed my page, they were in the order I wanted. Hooray, except the moment I add another forum it regenerates that "children" column (even if it is added to a completely unrelated forum) and it regenerates it back to the order they were created in.

I have absolutely no idea if any of this helps identify the issue, but I thought I would pass it along.

 

-- Additional Update --

After I re-order the forums, I looked at the "children" column and it IS updating to match the to the order the columns need to be in. What I can for a fact say is happening (and I don't know why) when a new forum is created it regenerates that "children" column to the original order the forums were created in. When I add a new forum, and see the forums are out of order again, that "children" column is back exactly the way it was before I re-ordered the columns.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 9, 2015 - 3:38 am

Let's step back a little please.

Right at the top you said that this behaviour happened with both normal forums and sub-forums so I tested with forums and I suggest Ike did as well. I find no problem.

In these later posts you fix on the 'children' column so that suggests this problem actually exists in sub-forums. I find no problem here either. But - I have been testing with the admin management of forums and making sure the ordering in the database is correct - which it seems to be no matter what I do. the order of the children array has no bearing on the display order which is, as you have noticed, controlled by the forum_seq column.

What I DO see and did not gather from your descriptions - is a mis-ordering of sub-forums (and ONLY sub-forums) when shown in forum view on the front end, They are correctly ordered in the Group View but yes - seem to be ordered on ID in the Forum View. I don't know if we are now talking about the same thing now or not but this is the only point I can detect any issue and will open a bug report to get it fixed up ASAP.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 9, 2015 - 5:46 am

OK - lots of investigation later and we do seem to be missing a sort operation in a couple of places.

If you are willing and comfortable doing so, I can give you some small code edits to try out...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Matthew BuPane
Member
sp_UserOfflineSmall Offline
Jul 9, 2015 - 11:30 am

Thank you so much for the reply, and I want you to know I TRULY appreciate your help!

Yes, perhaps I mixed up my terminology trying to give you as much information as possible. Sometimes my mind moves much faster than I can type (even though I type pretty fast) and even in re-reading it before I post, I see what I want and it doesn't always say what I meant it to say. 

The actual top levels forums, the ones with no parent and are on the front page with all the groups DO NOT resort. So, these are fine.

All forums that are a child object of one of those top level forums are the ones that get re-sorted every time a new forum is added. They get re-sorted to the order they were created in, and have to be re-ordered every time a new one is added. It does not matter whether a top level forum is added, or a sub-forum, the end result is the same.

I am more than happy to try out code edits for you, let me know what you'd like me to do and I am happy to help in any way possible.

Thanks again guys, I really appreciate it!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 9, 2015 - 11:50 am

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!

andy-signature.png
YELLOW
SWORDFISH
Avatar
Matthew BuPane
Member
sp_UserOfflineSmall Offline
Jul 9, 2015 - 12:46 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 9, 2015 - 9:10 pm

thanks for the confirmation...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626