I've had a little look online but cannot find a way to sort forums (not threads) alphabetically. Sure, I can change the order to be 1, 2, 3 and so on, but this could become inconvenient when adding, renaming and removing forums, which I will be doing frequently.
Is there an easy way to alphabetically sort these automatically?
My website is
theswitch.club, if that matters. A little embarrassing to link to as it's nowhere near ready (thankfully, most issues are easy to solve on my own), but hey, that's what the bold bullet point under the red text said to do.
Changing the order is the best and safest way to do this. It isn't that much of a pain when you remove/add/rename forums either. You could even split them up into multiples of 5/10 just incase you do
You could probably set up a custom task to update the display order.
(2016-11-29, 06:49 PM)laie_techie Wrote: [ -> ]You could probably set up a custom task to update the display order.
That looks like an interesting idea, and I can see how I'd add a task to the Task Manager, but I have no idea of what the PHP script would consist of. Is there any documentation for organising forums via a script?
I really don't see why you would want to do that. It is a lot more simplier to just organise them yourself.
(2016-11-30, 09:11 PM)Ben Wrote: [ -> ]I really don't see why you would want to do that. It is a lot more simplier to just organise them yourself.
![[Image: mylzvq.png]](https://camo.mybb.com/bff9f1656d918bfb0295f9cef2958478c1e41f07/68747470733a2f2f752e6e79612e69732f6d796c7a76712e706e67)
I would have to agree with Ben. As shown above you are given numbers to determine the order. I would put your sections in alphabetical order in notepad or something then number everything based on your list. In my opinion you shouldn't update your sections so often that it becomes an issue to maintain the order if your prefered manner. That being said it is an opinion, not a fact, it's up to the individual administrators on how they run their forum.
(2016-11-29, 10:50 PM)The Switch Club Wrote: [ -> ] (2016-11-29, 06:49 PM)laie_techie Wrote: [ -> ]You could probably set up a custom task to update the display order.
That looks like an interesting idea, and I can see how I'd add a task to the Task Manager, but I have no idea of what the PHP script would consist of. Is there any documentation for organising forums via a script?
I am at work and don't have time to test it, but the following is a good starting point:
Tasks are inside PHP files in the
inc/tasks directory. Let's say you want to name this task
Sort Forums. You'd create a file
inc/tasks/sort_forums.php. The main method would be
task_sort_forums($task).
This task would manipulate the
mybb_forums table (please use the correct prefix). The relevant fields are
fid (forum id),
name,
type (f=forum, c=category),
parentlist (includes comma-delimited path, including this forum / category), and
disporder.
function task_sort_forums($task) {
global $db, $cache;
$query = $db->simple_select("forums", "fid, name, type, substr(parentlist, 1, length(parentlist) - length(fid)) as parent, parentlist", '', array('order_by' => '4, 3, 2'));
$count = 1;
$old = '';
while ($row = $db=>fetch_array($query)) {
if ($row['parent'] != $old) {
$count = 1;
$old = $row['parent'];
}
$updated_record = array('disporder'=> $count);
$db->update_query(
'forums',
$updated_record,
'fid=' . intval($row['fid'])
);
$count++;
}
$db->free_result($query);
$cache->update_forums();
}
You would then need to go into ACP => Tools & Maintenance => Task Manager in order to schedule this task.