aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php40
1 files changed, 29 insertions, 11 deletions
diff --git a/index.php b/index.php
index 65c19bd69..a79f90166 100644
--- a/index.php
+++ b/index.php
@@ -243,33 +243,51 @@ if ( empty($page['is_external']) or !$page['is_external'] )
}
}
-
+ // image order
if ( $conf['index_sort_order_input']
and count($page['items']) > 0
and $page['section'] != 'most_visited'
and $page['section'] != 'best_rated')
{
- // image order
+ $preferred_image_orders = get_category_preferred_image_orders();
$order_idx = pwg_get_session_var( 'image_order', 0 );
-
+
+ // get first order field and direction
+ $first_order = substr($conf['order_by'], 9);
+ if (($pos = strpos($first_order, ',')) !== false)
+ {
+ $first_order = substr($first_order, 0, $pos);
+ }
+ $first_order = trim($first_order);
+
$url = add_url_params(
duplicate_index_url(),
array('image_order' => '')
);
- foreach (get_category_preferred_image_orders() as $order_id => $order)
+ $tpl_orders = array();
+ $order_selected = false;
+
+ foreach ($preferred_image_orders as $order_id => $order)
{
if ($order[2])
{
- $template->append(
- 'image_orders',
- array(
- 'DISPLAY' => $order[0],
- 'URL' => $url.$order_id,
- 'SELECTED' => ($order_idx == $order_id ? true:false),
- )
+ // force select if the field is the first field of order_by
+ if (!$order_selected && $order[1]==$first_order)
+ {
+ $order_idx = $order_id;
+ $order_selected = true;
+ }
+
+ $tpl_orders[ $order_id ] = array(
+ 'DISPLAY' => $order[0],
+ 'URL' => $url.$order_id,
+ 'SELECTED' => $order_idx==$order_id,
);
}
}
+
+ $tpl_orders[0]['SELECTED'] = !$order_selected; // unselect "Default" if another one is selected
+ $template->assign('image_orders', $tpl_orders);
}
// category comment