Changeset 23533


Ignore:
Timestamp:
Jun 25, 2013, 1:37:44 PM (11 years ago)
Author:
mistic100
Message:

bug:2931 photos sort order, "default" is meaningless
check the first criteria if available

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r23399 r23533  
    244244  }
    245245
    246 
     246  // image order
    247247  if ( $conf['index_sort_order_input']
    248248      and count($page['items']) > 0
     
    250250      and $page['section'] != 'best_rated')
    251251  {
    252     // image order
     252    $preferred_image_orders = get_category_preferred_image_orders();
    253253    $order_idx = pwg_get_session_var( 'image_order', 0 );
    254 
     254   
     255    // get first order field and direction
     256    $first_order = substr($conf['order_by'], 9);
     257    if (($pos = strpos($first_order, ',')) !== false)
     258    {
     259      $first_order = substr($first_order, 0, $pos);
     260    }
     261    $first_order = trim($first_order);
     262   
    255263    $url = add_url_params(
    256264            duplicate_index_url(),
    257265            array('image_order' => '')
    258266          );
    259     foreach (get_category_preferred_image_orders() as $order_id => $order)
     267    $tpl_orders = array();
     268    $order_selected = false;
     269   
     270    foreach ($preferred_image_orders as $order_id => $order)
    260271    {
    261272      if ($order[2])
    262273      {
    263         $template->append(
    264           'image_orders',
    265           array(
    266             'DISPLAY' => $order[0],
    267             'URL' => $url.$order_id,
    268             'SELECTED' => ($order_idx == $order_id ? true:false),
    269             )
     274        // force select if the field is the first field of order_by
     275        if (!$order_selected && $order[1]==$first_order)
     276        {
     277          $order_idx = $order_id;
     278          $order_selected = true;
     279        }
     280       
     281        $tpl_orders[ $order_id ] = array(
     282          'DISPLAY' => $order[0],
     283          'URL' => $url.$order_id,
     284          'SELECTED' => $order_idx==$order_id,
    270285          );
    271286      }
    272287    }
     288   
     289    $tpl_orders[0]['SELECTED'] = !$order_selected; // unselect "Default" if another one is selected
     290    $template->assign('image_orders', $tpl_orders);
    273291  }
    274292
Note: See TracChangeset for help on using the changeset viewer.