Author Topic: order categories by alphabetic order  (Read 21517 times)

0 Members and 1 Guest are viewing this topic.

Offline Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
order categories by alphabetic order
« on: February 23, 2006, 01:57:26 PM »
4images is the best, and the best can still get better!

Working on a categorized site full of images, I have noticed that sometimes its really difficult to organize it, suppose if u have 30 categories its really difficult for a visitor to go thorough all of them if they are not organized and ordered…

say for e.g. by alphabetic order,
now we can do it manualy, if we add 31st category, the trouble is that we have to organize it to order one by one, moving it one by one up or down…. it a troublesome job….

MOD request:
arrange categories in alphabetic order and make it separate like in blocks (see picture)



Thanks in advance
« Last Edit: February 23, 2006, 02:42:47 PM by maxpaul »

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: order categories by alphabetic order
« Reply #1 on: February 23, 2006, 03:05:23 PM »
http://www.4homepages.de/forum/index.php?topic=4312.0 <- searched for "sort categories by name"
http://www.4homepages.de/forum/index.php?topic=1254.0 <- searched for sort categories by name (also returned the topic above)
http://www.4homepages.de/forum/index.php?topic=9809.0 <- searched for rearrange categories
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 Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: order categories by alphabetic order
« Reply #2 on: February 23, 2006, 06:36:23 PM »
Ops! :oops: I know what u want to say me; I will do it more extensively next time
Thanks a lot for helping me

Ok, if apply all these mods then I will get it like this:

A1 A2 A3
A4 A5 A6
B1 B2 B3
B4 B5 B6
C1 C2 C3
C4 C5 C6

is there a way to make it

A1 A2 A3
A4 A5 A6

B1 B2 B3
B4 B5 B6

C1 C2 C3
C4 C5 C6

my site deals with names…. so I wanted to sort out the names into blocks

regards :wink:

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: order categories by alphabetic order
« Reply #3 on: February 24, 2006, 01:39:28 AM »
Having hard time picturing how it supposed to look like...so one idea is: create parent categories with name of alphabet letters and place all appropriate categories as subcategories into them.
i.e.
Parent categorysubcategories- Alan
- Alpha
- Alex
- Angel
Parent categorysubcategories- Barbara
- Biki
- Bob
Parent categorysubcategories- C1
- C2
- C3
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 Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: order categories by alphabetic order
« Reply #4 on: February 24, 2006, 07:55:04 AM »
hmmm I had thought of this, but I would like to do this only if no other alternative is available.... let me try to explain a bit more detailed, I am sure its an easy MOD,

Let us suppose the following are the categories, and on setting (3 columns in ACP) it would look like this: (after aplying the above mods)

Atomic Kitten        Ateshia            Ashanti
Anastacia              Alizee               Aishwarya
Aaliyah                  Amy Acker        Amber Easton
Buffy                     Billie                  Beyonce
Briana Banks         Blu Cantrell         Bai Ling
Caprice                 Carmella             China Chow
Charlotte C           Cindy Crawford


now imagine, if there were 200 names, it would look like a big block, and would not be comfortable for a visitor... :?

I would like to make it look like: (note the gap separating it out into alphabetic blocks.... would also be lovely if we can apply alternative text color like for e.g., row1 and row2)

Atomic Kitten        Ateshia            Ashanti
Anastacia              Alizee               Aishwarya
Aaliyah                  Amy Acker        Amber Easton

Buffy                     Billie                  Beyonce
Briana Banks         Blu Cantrell         Bai Ling

Caprice                 Carmella             China Chow
Charlotte C           Cindy Crawford


Hope this would not be very difficult......
Regards :D



Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: order categories by alphabetic order
« Reply #5 on: February 24, 2006, 11:09:50 AM »
yes that would be very good .. i have about 200 user categorys, and that sorting function would be great

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: order categories by alphabetic order
« Reply #6 on: February 24, 2006, 02:30:48 PM »
Ok, lets try this:
asuming you've installed the code that show categories left-to-right (last link above)
find includes/functions.php:
Code: [Select]
  $categories .= "<tr>\n";
  foreach ($visible_cat_cache as $key => $category_id) {
Replace with:
Code: [Select]
  $alpha = "";
  $row_bg_number = 1;
  $categories .= "<tr class=\"catbgcolor".$row_bg_number."\">\n";
  foreach ($visible_cat_cache as $key => $category_id) {
    $letter = strtolower(substr($cat_cache[$category_id]['cat_name'], 0, 1));
    if ($alpha && $letter != $alpha)
    {
      if ($count) $categories .= "</tr>\n<tr>\n";
      $categories .= "<td>&nbsp;</td>\n</tr>\n";
      $categories .= "<tr class=\"catbgcolor".$row_bg_number."\">\n";
      $row_bg_number = ($row_bg_number++ % 2 == 0) ? 1 : 2;
      $count = 0;
    }
    $alpha = $letter;

Then in your style.css you can add two new styles:
Code: [Select]
.catbgcolor1 {
...
}
.catbgcolor2 {
...
}
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 Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: order categories by alphabetic order
« Reply #7 on: February 24, 2006, 02:51:13 PM »
Thanks V@no, it works
I have a few questions:
This only groups subcategories or categories with similar starting alphabets, but does not order it by alphabetic order?

How do we reduce the distance between the blocks?

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: order categories by alphabetic order
« Reply #8 on: February 24, 2006, 11:46:59 PM »
It does not sort the categories, but the links above do.
the distance you can try modify
Code: [Select]
      $categories .= "<td>&nbsp;</td>\n</tr>\n";With something like:[qcode]      $categories .= "<td><div style=\"height: 1px; overflow: hidden;\">&nbsp;</div></td>\n</tr>\n";[/qcode]
Or you can simply remove the code in red, if you dont want have any spacing.
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 Eagle Eye

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: order categories by alphabetic order
« Reply #9 on: February 25, 2006, 11:21:51 AM »
thanks, working perfect!  :D

Offline jamstave

  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: order categories by alphabetic order
« Reply #10 on: July 06, 2007, 04:54:40 AM »
How do i put the letter top of the name like this.


A
A1 A2 A3
A4 A5 A6

B
B1 B2 B3
B4 B5 B6

C
C1 C2 C3
C4 C5 C6

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: order categories by alphabetic order
« Reply #11 on: July 06, 2007, 10:28:14 AM »
... use $letter instead of &nbsp; ...
Code: [Select]
$categories .= "<td>".$letter."</td>\n</tr>\n";
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline sami1255

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: order categories by alphabetic order
« Reply #12 on: July 26, 2007, 03:34:17 PM »
Excellent !.. Awesome.. ! 4images is not only great by itself but it has been maintained by some great programmers..

well, kindly if you please tell how to show BLOCK Letters instead of lower case.. Also my gallery isnt displaying first letter 'A' at all..

see www.celebritysexshot.com

Offline jamstave

  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: order categories by alphabetic order
« Reply #13 on: February 24, 2009, 02:14:01 AM »
Also It's not showing the first letter of the list it's showing like this


1111
111

2
222
22

3
333
3333

4
4444
44444

A
AAAA
AA

B
BBB
BBBB

i want to show first letter too

1
1111
111

2
222
22

3
333
3333

4
4444

And  i want show like this 0-9,  rather than showing 1,2,3,4,

some thing like this

0-9
11
22
333
3333
44

A
AAAA
AA

B
BBB
BBBB

Can some one help me to do this.

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: order categories by alphabetic order
« Reply #14 on: February 24, 2009, 03:38:50 AM »
Replace
    if ($alpha && $letter != $alpha)

With:
    if ($letter != $alpha)
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)