Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: proto-man on November 15, 2004, 07:03:03 PM

Title: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: proto-man on November 15, 2004, 07:03:03 PM
Just have one quick n00b question. Is there any way to make the theme list in alphabetical order. For example, when you are choosing your own theme, i realized that the themes are in list of the date added, i think,  not in alphabetical order. Is there any way to make it happen. Just wondering.


Moderator-edit: subject clarified
Title: Re: Quick Newb Question
Post by: [Unknown] on November 15, 2004, 11:04:11 PM
Currently, that would take code modification, but it's possible and indeed may be done in the future.

-[Unknown]
Title: Re: Quick Newb Question
Post by: proto-man on November 17, 2004, 03:34:44 PM
How hard or easy would it be? If it is quick and easy, someone might be willing to do it for me if they have time.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: [Unknown] on November 20, 2004, 09:13:24 PM
Find, Sources/Themes.php:
ksort($context['available_themes']);

Replace:
$temp = array();
foreach ($context['available_themes'] as $theme)
$temp[$theme['name']] = $theme['id'];

ksort($temp);

$temp2 = $context['available_themes'];
$context['available_themes'] = array();
foreach ($temp as $id)
$context['available_themes'][$id] = $temp2[$id];


That should, in theory, do what you want.

-[Unknown]
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: proto-man on November 20, 2004, 10:52:54 PM
Unfortunately, for some reason, that doesn't work. When i try the code, this is what i get:

(http://img96.exs.cx/img96/760/theme-not-working.jpg)

However with the original code, this is what i get:

(http://img96.exs.cx/img96/2403/theme-working.jpg)
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: andrea on November 21, 2004, 01:53:37 AM
Modifying sources because you wish the themes be displayed in a different order looks to me like "shooting sparrows with cannons" (as we say in german).

This looks like a much simpler alternative to me:

- delete the known themes from the database by clicking the red "x" in the admin menu
- re-add the known themes into the database with the admin menu option (Install a New Theme - From a directory on the server)
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: [Unknown] on November 21, 2004, 02:53:10 AM
Oops, sorry - I made one big typo that broke it.  Try...

Find, Sources/Themes.php:
ksort($context['available_themes']);

Replace:
$temp = array();
foreach ($context['available_themes'] as $theme)
$temp[$theme['name']] = $theme['id'];

ksort($temp);

$temp2 = $context['available_themes'];
$context['available_themes'] = array();
foreach ($temp as $id)
$context['available_themes'][$id] = $temp2[$id];


-[Unknown]
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: proto-man on November 21, 2004, 01:53:23 PM
thanx unknown. i will check it out.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: proto-man on November 24, 2004, 10:38:56 PM
yes, that worked. Just one more thing. It really isn't much of a deal for me but i would like to know if you could od something for me. All my themes are in Alphabetical order but i wondering if i could still have my default theme at the top. Like i said before. Really isn't much of a deal but if you could do it, it would be much appreciated. Thanx for all the support you've given me. Still wondering how you became a genius at only nineteen.  ???
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: [Unknown] on November 24, 2004, 11:22:18 PM
Again, Sources/Themes.php:
ksort($context['available_themes']);

Replace:
$temp = array();
foreach ($context['available_themes'] as $theme)
$temp[$theme['name']] = $theme['id'];

ksort($temp);

$temp2 = $context['available_themes'];
$context['available_themes'] = array($temp2[0]);
foreach ($temp as $id)
{
if ($id != 0)
$context['available_themes'][$id] = $temp2[$id];
}


That *should* do what you wanted...

-[Unknown]
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: ViSioNaRy on November 25, 2004, 02:30:19 AM
That is a sweet tweak, especially with 35 themes.  :D
Nice and neat now thank you! You the best!
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: proto-man on November 25, 2004, 05:31:58 PM
yes. thanx unknown. you are the best
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: kat on August 26, 2006, 04:11:34 PM
I know that this is a bit old, now...

However, being a relative NooB, I found this worked, brilliantly, with 1.1RC3!

Is there a way of doing the same with the themes as they appear in the admin section?
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: ViSioNaRy on March 23, 2007, 01:54:02 PM
Is there a way to get 1.1.2 to alphabetize themes?

This really needs to be the default.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: aerojad on August 27, 2007, 04:05:22 AM
Sweet tip!  Just helped me out a heck of a lot.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: dan2507 on January 31, 2012, 05:04:54 PM
Sorry for pushing this old topic back, but I could only find this one related to the themes order - and this does not work on SMF 2.0.2.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Home 4 Answers on February 01, 2012, 01:46:58 AM
Looking for the same thing here, any ideas?
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: dan2507 on February 02, 2012, 02:46:42 PM
Seems that there isn't an easy solution or mod available for this basic request. :(
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Ninja ZX-10RR on November 09, 2014, 10:37:30 AM
Bump for the awesome [Uknown]. Still works after freaking TEN years with 2.0.9. Unbelievable, I wish you could read me, thanks, after ten years. Should have been into core a LONG while ago.
You just made me post in a topic I hadn't posted in just to say this.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Arantor on November 09, 2014, 10:41:43 AM
Funny how last time you spoke of Unknown I had to rebuke you for complaining about him.

Also note, at the time that post was made I'm pretty sure Unknown was SMF lead dev... as in, it was left the way it was for a reason.
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Ninja ZX-10RR on November 09, 2014, 10:47:33 AM
I know how I spoke about him because I still can't understand something about him, I wish I could talk to him about that since the way I saw it (and still see) looks quite awful.
But still looking at very old topics I saw him supporting everywhere, which makes me not understanding even more, I just commented that the solution was plain epic if it still works after 2.0 and also after 10 years :)

P.s. I would have bet my house you would have been saying exactly what you said ;) I started to understand you, somehow :)
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Steve on November 10, 2014, 10:21:46 AM
Glad you bumped this ... love the tweak!
Title: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Post by: Ninja ZX-10RR on November 10, 2014, 12:31:15 PM
That's exactly the reason why I did it, we won't be the only ones, probably :)