MyBB Community Forums

Full Version: Is is possible to have Thread Prefix as Priority list?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

Is is possible to have Thread Prefix as Priority list?

[Image: 9b0bbaf1d2.png]

I want Other in the last and some city names on the top.

Regards.
Prefixes are stored in database in the order entered.
As they are added, edited, deleted in AdminCP they are updated into the cache in alphabetical order.
When they are used in normal forum operations they are drawn from cache.

I may be overlooking something but it appears the sort occurs in one place in /inc/class_datacache.php in line 1178.

1178          $query = $db->simple_select("threadprefixes", "*", "", array('order_by' => 'prefix', 'order_dir' => 'ASC'));

If you change 'order_by' => 'prefix' to 'order_by => 'pid', you will get your desired sort order. Of course, you will want to enter your list of prefixes in the desired order.

This is a core edit, so you will need to verify the change is needed to be done again every time you update forum software version.

Another possibility is to modify the table to add a column for sort order and changing line 1178 appropriately. This approach might be better if you intend to be changing the prefix list in future. But for a simple list like you show, the above will work.

Tested this method on my forum and it works as described.
...you also could rename your prefixes in ACP with front numbers, like this:
[attachment=45055]
If you have more than 9 prefixes then you have to start numbers with 2 digits, like
01. Skardu
02. ....
etc.

This way wouldn't requires any core code changes.
Edit to add:

You can change the sort order of your prefixes without a core edit if they start with a number or other code, i.e.

1. Gilgit
2. Hyderabad
10. Other

although you might need 2 characters for more than 9 in the list.

or let the city names sort alphabetically, and add the last one as ~~Other. I chose ASCII 7E character so it sorts last alphabetically.
This method is not tested

---------------

Looks like Sven was thinking simpler. Smile
(2022-04-16, 12:47 PM)SvePu Wrote: [ -> ]...you also could rename your prefixes in ACP with front numbers, like this:

If you have more than 9 prefixes then you have to start numbers with 2 digits, like
01. Skardu
02. ....
etc.

This way wouldn't requires any core code changes.

(2022-04-16, 12:51 PM)HLFadmin Wrote: [ -> ]Edit to add:

You can change the sort order of your prefixes without a core edit if they start with a number or other code, i.e.

1. Gilgit
2. Hyderabad
10. Other

although you might need 2 characters for more than 9 in the list.

or let the city names sort alphabetically, and add the last one as ~~Other. I chose ASCII 7E character so it sorts last alphabetically.
This method is not tested

---------------

Looks like Sven was thinking simpler. Smile

Worked. Thanks!
Prepending a number of invisible characters, equivalent to desired position in the list, might also work.