Sortorder problem in categories plugin

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
DeepKeeper

Sortorder problem in categories plugin

Post by DeepKeeper »

In Russian version og Serendipity 0.8.2 the displaying sortorder is not alphabetical, but by order category was created.

Could any one help to change it?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Sortorder problem in categories plugin

Post by garvinhicking »

In include/plugin_internal.inc.php there is a class "serendipity_categories_plugin". In its generate_content() method it uses this function to display the list of categories in the sidebar:

Code: Select all

        $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category);
This function serendipity_fetchCategories is defined in include/functions_entries.inc.php. It uses this SQL statement:

Code: Select all

ORDER BY category_name
This means, the serendipity code is perfectly in order. It is simply your database that can not sort by correct charsets. If you are using MySQL, you need to use version 4.1 and use Russian charset collations; then the ordering will be alright.

This is an issue of the database; if we used a PHP sorting algorithm for that data, it would cost a lot of perfomance, which is why we cannot include that.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
winkiller
Regular
Posts: 77
Joined: Tue May 17, 2005 7:52 pm
Location: Munich, Germany
Contact:

Post by winkiller »

I looked into this in 0.9 and wondered why there is a config parameter named sort_order, will this then be in PHP or MySQL?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

The sort_order directive is used for MySQL sorting.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Guest

Post by Guest »

really, MySQL database problem...

Where it will be most correctly to change sortorder to by categoryid?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I've just committed a patch to the include/plugin_internal.inc.php of our SVN.

The patch is easy if you just change this:

Code: Select all

            case 'sort_order':
                $select = array();
                $select['category_name']        = CATEGORY;
                $select['category_description'] = DESCRIPTION;
                $select['categoryid']           = 'ID';
                $select['none']                 = NONE;
                $propbag->add('type',         'select');
                $propbag->add('name',         SORT_ORDER);
                $propbag->add('description',  '');
                $propbag->add('select_values', $select);
                $propbag->add('default',     'category_name');
                break;
Note the new $select['categoryid'] line in that plugin file.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
deepkeeper_

Post by deepkeeper_ »

tnx)

jogging - can we realise the sort by category_image? :lol:

(i tried, but with no result...)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Sure, you can add it just like you added "categoryid". But I think this is not useful for our default plugin installation...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply