diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-04-30 17:11:25 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-04-30 17:11:25 +0000 |
commit | 1d5af70e5e762a911dce3d5ddd413bcdc41dbde1 (patch) | |
tree | 0c591846843c5589e69da5fa5ad9c8be7bfa67e0 | |
parent | 4bd0efd3eacaa8e11b6b711e04e0c527ad926a16 (diff) |
bug 26 : When categories tree has category ids not in ascending order, the order of display still uses ids order. Corrected using categories.uppercats order
git-svn-id: http://piwigo.org/svn/branches/release-1_3@412 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/functions_category.inc.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index ec7d97a51..044158715 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -287,17 +287,26 @@ function get_cat_info( $id ) } $cat['comment'] = nl2br( $cat['comment'] ); - $cat['name'] = array(); + // first, we retrieve the names of upper categories in the default order + // (not the correct one automatically) + $buffers_name = array(); - $query = 'SELECT name'; + $query = 'SELECT id, name'; $query.= ' FROM '.PREFIX_TABLE.'categories'; $query.= ' WHERE id IN ('.$cat['uppercats'].')'; - $query.= ' ORDER BY id ASC'; $query.= ';'; $result = mysql_query( $query ); while( $row = mysql_fetch_array( $result ) ) { - array_push( $cat['name'], $row['name'] ); + $buffer_names[$row['id']] = $row['name']; + } + + // then we reorder the names with the order given in the + // categories.uppercats database field + $cat['name'] = array(); + + foreach ( explode( ',', $cat['uppercats'] ) as $id_uppercat ) { + array_push( $cat['name'], $buffer_names[$id_uppercat] ); } return $cat; |