Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: proto-man in November 15, 2004, 07:03:03 NACHMITTAGS

Titel: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: proto-man in November 15, 2004, 07:03:03 NACHMITTAGS
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
Titel: Re: Quick Newb Question
Beitrag von: [Unknown] in November 15, 2004, 11:04:11 NACHMITTAGS
Currently, that would take code modification, but it's possible and indeed may be done in the future.

-[Unknown]
Titel: Re: Quick Newb Question
Beitrag von: proto-man in November 17, 2004, 03:34:44 NACHMITTAGS
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.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: [Unknown] in November 20, 2004, 09:13:24 NACHMITTAGS
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]
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: proto-man in November 20, 2004, 10:52:54 NACHMITTAGS
Unfortunately, for some reason, that doesn't work. When i try the code, this is what i get:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg96.exs.cx%2Fimg96%2F760%2Ftheme-not-working.jpg&hash=3db4fa85ca3f9046f139950897508cc86f3e0a14)

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

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg96.exs.cx%2Fimg96%2F2403%2Ftheme-working.jpg&hash=a46b918284da828f967084a58e369e413e8d7816)
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: andrea in November 21, 2004, 01:53:37 VORMITTAG
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)
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: [Unknown] in November 21, 2004, 02:53:10 VORMITTAG
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]
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: proto-man in November 21, 2004, 01:53:23 NACHMITTAGS
thanx unknown. i will check it out.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: proto-man in November 24, 2004, 10:38:56 NACHMITTAGS
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.  ???
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: [Unknown] in November 24, 2004, 11:22:18 NACHMITTAGS
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]
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: ViSioNaRy in November 25, 2004, 02:30:19 VORMITTAG
That is a sweet tweak, especially with 35 themes.  :D
Nice and neat now thank you! You the best!
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: proto-man in November 25, 2004, 05:31:58 NACHMITTAGS
yes. thanx unknown. you are the best
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: kat in August 26, 2006, 04:11:34 NACHMITTAGS
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?
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: ViSioNaRy in März 23, 2007, 01:54:02 NACHMITTAGS
Is there a way to get 1.1.2 to alphabetize themes?

This really needs to be the default.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: aerojad in August 27, 2007, 04:05:22 VORMITTAG
Sweet tip!  Just helped me out a heck of a lot.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: dan2507 in Januar 31, 2012, 05:04:54 NACHMITTAGS
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.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Home 4 Answers in Februar 01, 2012, 01:46:58 VORMITTAG
Looking for the same thing here, any ideas?
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: dan2507 in Februar 02, 2012, 02:46:42 NACHMITTAGS
Seems that there isn't an easy solution or mod available for this basic request. :(
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Ninja ZX-10RR in November 09, 2014, 10:37:30 VORMITTAG
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.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Arantor in November 09, 2014, 10:41:43 VORMITTAG
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.
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Ninja ZX-10RR in November 09, 2014, 10:47:33 VORMITTAG
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 :)
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Steve in November 10, 2014, 10:21:46 VORMITTAG
Glad you bumped this ... love the tweak!
Titel: Re: Quick Newb Question / HowTo list the themes in alphabetical order?
Beitrag von: Ninja ZX-10RR in November 10, 2014, 12:31:15 NACHMITTAGS
That's exactly the reason why I did it, we won't be the only ones, probably :)