4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Eagle Eye on February 23, 2006, 01:57:26 PM

Title: order categories by alphabetic order
Post by: Eagle Eye 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)

(http://img55.imageshack.us/img55/6844/blocks6zc.jpg)

Thanks in advance
Title: Re: order categories by alphabetic order
Post by: V@no 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
Title: Re: order categories by alphabetic order
Post by: Eagle Eye 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:
Title: Re: order categories by alphabetic order
Post by: V@no 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
Title: Re: order categories by alphabetic order
Post by: Eagle Eye 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


Title: Re: order categories by alphabetic order
Post by: trez 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
Title: Re: order categories by alphabetic order
Post by: V@no 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 {
...
}
Title: Re: order categories by alphabetic order
Post by: Eagle Eye 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?
Title: Re: order categories by alphabetic order
Post by: V@no 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.
Title: Re: order categories by alphabetic order
Post by: Eagle Eye on February 25, 2006, 11:21:51 AM
thanks, working perfect!  :D
Title: Re: order categories by alphabetic order
Post by: jamstave 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
Title: Re: order categories by alphabetic order
Post by: mawenzi on July 06, 2007, 10:28:14 AM
... use $letter instead of &nbsp; ...
Code: [Select]
$categories .= "<td>".$letter."</td>\n</tr>\n";
Title: Re: order categories by alphabetic order
Post by: sami1255 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 (http://www.celebritysexshot.com)
Title: Re: order categories by alphabetic order
Post by: jamstave 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.
Title: Re: order categories by alphabetic order
Post by: V@no on February 24, 2009, 03:38:50 AM
Replace
    if ($alpha && $letter != $alpha)

With:
    if ($letter != $alpha)
Title: Re: order categories by alphabetic order
Post by: jamstave on February 24, 2009, 04:19:32 AM
Thank you very much v@no it's working good now. Is it possible to show the numbers 0-9 like this

0-9
111 (cat)
2222  (cat)
22 (cat)
33 (cat)
44 (cat)
999 (cat)

A
AAA (cat)

B
BBB (cat)
Title: Re: order categories by alphabetic order
Post by: V@no on February 24, 2009, 06:56:49 AM
Below    $letter = strtolower(substr($cat_cache[$category_id]['cat_name'], 0, 1));


Insert this:
    if ($letter >= "0" && $letter <= "9")
      $letter = "0-9";
Title: Re: order categories by alphabetic order
Post by: jamstave on February 24, 2009, 02:50:36 PM
Thank you soo much v@no it's working now.


Jamestave.