Changeset 412


Ignore:
Timestamp:
Apr 30, 2004, 7:11:25 PM (20 years ago)
Author:
z0rglub
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/include/functions_category.inc.php

    r406 r412  
    288288  $cat['comment'] = nl2br( $cat['comment'] );
    289289
    290   $cat['name'] = array();
    291 
    292   $query = 'SELECT name';
     290  // first, we retrieve the names of upper categories in the default order
     291  // (not the correct one automatically)
     292  $buffers_name = array();
     293
     294  $query = 'SELECT id, name';
    293295  $query.= ' FROM '.PREFIX_TABLE.'categories';
    294296  $query.= ' WHERE id IN ('.$cat['uppercats'].')';
    295   $query.= ' ORDER BY id ASC';
    296297  $query.= ';';
    297298  $result = mysql_query( $query );
    298299  while( $row = mysql_fetch_array( $result ) )
    299300  {
    300     array_push( $cat['name'], $row['name'] );
     301    $buffer_names[$row['id']] = $row['name'];
     302  }
     303
     304  // then we reorder the names with the order given in the
     305  // categories.uppercats database field
     306  $cat['name'] = array();
     307 
     308  foreach ( explode( ',', $cat['uppercats'] ) as $id_uppercat ) {
     309    array_push( $cat['name'], $buffer_names[$id_uppercat] );
    301310  }
    302311 
Note: See TracChangeset for help on using the changeset viewer.