Topic: "Select your preferred style" order

I have just added a bunch of new styles to my punbb forum, and the drop down in the profile section has the styles in a seemingly orderless way. Is there a way to make this dropdown show the styles sorted alphabetically?

I havent checked into updating the code myself, I was first going to check if there was already a way I wasn't aware of.

Thanks.

Re: "Select your preferred style" order

Try playing with asort?

3 (edited by badrad 2005-05-14 22:21)

Re: "Select your preferred style" order

So in other words, its not sorted by default?

It seems the expected behavior would be for styles to be in alphabetical order.

Its an easy fix. Find this line in profile.php (line 1352 in unmodded punbb):

// Only display the style selection box if there's more than one style available

and immediatly before it add

        //sort styles alphabetically
        asort($styles);
        reset($styles);

I'm new here. What is the best way to get bug fixes to Rickard? Does he check these forums regularly? Should I poist in the bugs section? Or email him?

4

Re: "Select your preferred style" order

Rickard checks the forums regularly (normally). Don't post something in the bugs section unless it really is a bug i.e. something obvioulsly doesn't work as intended. If something is working as designed but you think it could have been designed better then best to put it in PunBB Discussions or Feature Requests.

Re: "Select your preferred style" order

Actually, the 100% proper way is:

        //sort styles alphabetically
        natsort($styles);
        reset($styles);

Re: "Select your preferred style" order

Consider it done.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: "Select your preferred style" order

Turns out, the sort order of items returned by the dir class in PHP is system dependant. It's returned sorted on Windows, but not in *NIX.

Anyway, here's the fix: http://dev.punbb.org/changeset/201

I added sorting to the language drop-down as well. The call to reset() is not required.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: "Select your preferred style" order

Rickard wrote:

Turns out, the sort order of items returned by the dir class in PHP is system dependant.

Yea, I figured as much.

Rickard wrote:

The call to reset() is not required.

OK, I wasn't sure so I had added it.

Thanks Rickard!