Quick Newb Question / HowTo list the themes in alphabetical order?

Started by proto-man, November 15, 2004, 07:03:03 PM

Previous topic - Next topic

proto-man

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

[Unknown]

Currently, that would take code modification, but it's possible and indeed may be done in the future.

-[Unknown]

proto-man

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.

[Unknown]

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]

proto-man

Unfortunately, for some reason, that doesn't work. When i try the code, this is what i get:



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


andrea

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)

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

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]


proto-man

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.  ???

[Unknown]

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]

ViSioNaRy

That is a sweet tweak, especially with 35 themes.  :D
Nice and neat now thank you! You the best!
ViSioNaRy   ;D

proto-man


kat

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?

ViSioNaRy

Is there a way to get 1.1.2 to alphabetize themes?

This really needs to be the default.
ViSioNaRy   ;D

aerojad


dan2507

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.


dan2507

Seems that there isn't an easy solution or mod available for this basic request. :(

Ninja ZX-10RR

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.
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Arantor

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.

Advertisement: