Page 1 of 1

Sortorder problem in categories plugin

Posted: Thu Jun 30, 2005 9:52 pm
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?

Re: Sortorder problem in categories plugin

Posted: Fri Jul 01, 2005 1:23 pm
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

Posted: Fri Jul 01, 2005 4:20 pm
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?

Posted: Fri Jul 01, 2005 6:52 pm
by garvinhicking
The sort_order directive is used for MySQL sorting.

Regards,
Garvin

Posted: Sat Jul 02, 2005 5:10 pm
by Guest
really, MySQL database problem...

Where it will be most correctly to change sortorder to by categoryid?

Posted: Sun Jul 03, 2005 11:48 am
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

Posted: Sun Jul 03, 2005 3:33 pm
by deepkeeper_
tnx)

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

(i tried, but with no result...)

Posted: Sun Jul 03, 2005 3:44 pm
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