Recent Topics

1 Feb 20, 2005 16:09    

How do I list categories in an order besides alphabetical in the categories section?


2 Feb 22, 2005 06:40

I don't see a simple answer to your question.

The categories are pulled recursively in the _categories.php file. And there is a warning comment at this point:

* WARNING: the category list is displayed recursively.
* This is a little tricky. Don't modify below unless you really know what you're doing!

The problem is compounded by the fact that categories can have sub-categories and they must always match up correctly. (It's not just like blasting thru a list and saying - give it to me in random order, because the subcategories must always MATCH their parent categories).

I'm not a PHP guy, but I can see there isn't a direct query to the database, it's all done through a query function "cat_query()" and I couldn't find any meaningful doc on that in the technical section.

If you're a PHP/programming person, maybe you can jumble up the array it generates, somehow, but it's all a tad bit over my head.

Sorry I can't help, maybe someone else can, but I didn't want you to think that you were being ignored. It's just that your request isn't a simple one ... at least it isn't, for me. ;)

There IS however, a really AWFUL way of doing what you want, via CSS. What you CAN do is assign a unique class name to EACH category in the list (I do that now, coloring my categories to match the blog header ... [url=]see the effect[/url]

You can change the echo statement in the 'function cat_list_before_each', to something like

echo '<span class=''.$cat_name.'"><a href...  [blah, blah - and end it with]  ...</span>';

So now, each category in the list, including subcats, will have a unique class name.

In the CSS file, you can position each label, using the .[cat_name] selector & a {position:relative; top:XXpx } just moving them up and down to your hearts content.

It's clunky, but would work. :-/

Hope this helps.

3 Feb 22, 2005 09:29

Thanks for your response.... nice site, by the way.

Clunky works for me. I'll give it a shot. I'm not a PHP guy, either, but changing some code is no problem.

4 Feb 23, 2005 19:55

How's it coming?

Did it work?

What's your site address?

5 Feb 25, 2005 13:45

Guess what! I took the easy way and re-named some of my categories. it took a little thinking but I saved myself the trouble of messing up my site (grin)

I know.. that would be cheating.

I would cite the ability to organize categories as a future feature request, if any b2e developer is listening.

To me that, and the ability to search specific blogs only, would make it a perfect blog script.

6 Feb 25, 2005 14:27

Glad you found a way around the issue, but if you want the hack isn't so hard. Well, if you want them in numberetical order instead of alphabetical it's not so hard. In b2evocore/_functions_cats.php look for the cat_load_cache() function around line 290 then change ORDER BY cat_name to ORDER BY cat_ID. It's a few lines down - maybe 307 but I just closed the file so I'm not sure. I tested it on a plain jane v11 installation and saw where the category list in the sidebar was not alphabetical anymore. I didn't look over the whole thing to figure out what else may have gotten tweaked, but I doubt anything. if you're into checking it out, but I'll probably pull the hack one day. It's my playground so I like to keep it clean.

7 Feb 25, 2005 14:27

Wimp! ;)

Francois (and others) will hear you better, IF you put your request in the "Feature Request" forum. But I hear you. When I first got started with b2evo, I was sad to learn that the only way to list categories was alphabetically. I thought there should be a number of ways:

1) Most recent (categories posted to most recently would 'float' to the top of the list)
2) # posts (cats w/most posts @ top ... down to least posts)
3) user defined ... let user pick the way.

Unfortunately, the "perfect" blog is different for everyone! (They're working on it, though! It's pretty darn good now, imo ;) )

PS - I used the CSS technique I described above to HIDE a category, yesterday (visibility:hidden), but if renaming works for you ... GREAT!

EDIT - Ya beat me Ed (by seconds?)... and THANKS ... I didn't know that, tho alphabetical works just fine for me

8 Feb 25, 2005 14:46

Ordering by time of creation is pretty much the same as cat number. Reversing it is something I didn't look at but should be easily doable - just put an ASC after the ORDER BY cat_ID thing. Sorting by quantity of posts would be truly tough because of the recursive subcat thing, or at least it seems that way in my head right now. Especially since subcats can be the main cat for a post and a main cat can be the post's subcat. User-definable would be the ultimate, but what a back office that would be! I think the more you think about the code behind it all and the end result of any given order the more alphabetical makes sense. I dunno. When I first started with b2evo I made my cats alphabetically and numerically match, but I'm up to 105 cats now so it's like *not* worth any effort to structure them specially. To me anyway.

9 Mar 12, 2005 16:06

Well mine don't seem to be working alphabetically at all. *scratches head* I have created a few new blogs to work on designwise but in the blog list they are not showing alphabetically but by ID number. Can I fix this so they are alphabetical? I want it that way because if I add a new blog later down the road it would appear out of alphabetical alignment...

Thanks :)


Form is loading...

CMS software – This forum is powered by b2evolution CMS, a complete engine for your website.