Author Topic: Category Dropdown Ordering  (Read 8975 times)

0 Members and 1 Guest are viewing this topic.

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Category Dropdown Ordering
« on: April 12, 2006, 12:51:13 AM »
Can someone tell me how to order the category dropdown from A to Z instead of category ID ordering?

And how do show only MAIN CATS there?

thanks in advance.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Category Dropdown Ordering
« Reply #1 on: April 12, 2006, 01:44:17 AM »
To show only main cats, replace in includes/functions.php
Code: [Select]
  $drop_down_cat_cache = $cat_parent_cache;
with:
Code: [Select]
  $drop_down_cat_cache[0] = $cat_parent_cache[0];

And to sort them by name, below that line, insert:
Code: [Select]
  uasort($drop_down_cat_cache[0], "catsortname");
then, at the very end of the file, ABOVE closing ?> insert:
Code: [Select]
function catsortname($a, $b)
{
  global $cat_cache;
  return strcasecmp($cat_cache[$a]['cat_name'], $cat_cache[$b]['cat_name']);
}
« Last Edit: April 12, 2006, 06:41:47 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #2 on: April 12, 2006, 01:46:21 AM »
thanks alot v@no, i'll try that out :)

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #3 on: April 12, 2006, 02:40:34 AM »
V@no, only main cats appear like I wanted, but the sort is not good. Categories are all mixed, no alphabetical order after instering your code. what's wrong?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Category Dropdown Ordering
« Reply #4 on: April 12, 2006, 06:41:59 AM »
try now
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #5 on: April 12, 2006, 12:47:57 PM »
V@NO PERFECT!!!!  8)

Thanks again!

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #6 on: May 30, 2006, 08:16:08 PM »
V@no do you think you can help me now again:

The categories show exactly as a I wanted in normal pages, but when I try to edit a photo and move it to a subdir, the subdirs dont show up, just the main catgs.

what do I have to change in order to the admin edit image area show the drop down with all the subcats?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Category Dropdown Ordering
« Reply #7 on: May 31, 2006, 12:16:11 AM »
You can try replce the two new lines from above with this:
Code: [Select]
  if (defined("IN_CP"))
  {
    $drop_down_cat_cache = $cat_parent_cache;
  }
  else
  {
    $drop_down_cat_cache[0] = $cat_parent_cache[0];
    uasort($drop_down_cat_cache[0], "catsortname");
  }

This will show normal dropdown in ACP.
« Last Edit: May 31, 2006, 06:11:45 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #8 on: May 31, 2006, 02:47:00 AM »
thanks for the help, but it isnt working, the only change I see is the ordering, it only changes the ordering. it doesnt show the sub categories in the CP.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Category Dropdown Ordering
« Reply #9 on: May 31, 2006, 06:13:02 AM »
Hmmm...what's wrong with me? :S try now, I've update the post above...
Now it should only "sort" dropdown on the "main" site, and should not affect ACP.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kindian

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Category Dropdown Ordering
« Reply #10 on: May 31, 2006, 06:57:26 PM »
damn you V@no!!!! that worked like a charm!!!  :D

you're the master, thanks again for yout help!!!!!!!