ok, did it myself
This version uses
sessions (that means, that after each time u open new browser window, it will reset settings to default).
If u want it uses
cookies u'll need do some changes that I posted on
3rd page1. Open
/includes/page_header.php1.1. Find:
"charset" => $lang['charset'],
1.2. Add after:
"image_order" => $lang['image_order'],
"image_sort" => $lang['image_sort'],
1.3. At the end of the file, just before
?> add this code:
A - Sessions based (ones browser window is closed sorting options will be gone)
//-----------------------------------------------------
//--- Set Images Sort ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['imagesorder'])) {
$imagesorder = $HTTP_POST_VARS['imagesorder'];
if ($imagesorder) {
$site_sess->set_session_var("imgs_order", $imagesorder);
$session_info['imgs_order'] = $imagesorder;
}
}
if (isset($session_info['imgs_order'])) {
$config['image_order'] = $session_info['imgs_order'];
}
if (isset($HTTP_POST_VARS['imagessort'])) {
// $imagessort = intval($HTTP_POST_VARS['imagessort']);
$imagessort = $HTTP_POST_VARS['imagessort']; //Added 03-11-2003
if ($imagessort) {
$site_sess->set_session_var("imgs_sort", $imagessort);
$session_info['imgs_sort'] = $imagessort;
}
}
if (isset($session_info['imgs_sort'])) {
$config['image_sort'] = $session_info['imgs_sort'];
}
//----End Images Sort----------------------------------
//-----------------------------------------------------
//--- Set Images Sort Dropdown ------------------------
//-----------------------------------------------------
$imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";
foreach ($image_order_optionlist as $key => $val) {
$imgsort_dropdown .= "<option value=\"$key\"";
if ($config['image_order'] == $key) {
$imgsort_dropdown .= " selected=\"selected\"";
}
$imgsort_dropdown .= ">".$val."</option>\n";
}
$imgsort_dropdown .= "</select>\n";
foreach ($image_sort_optionlist as $key => $val) {
$imgsort_dropdown .= "<INPUT type=\"radio\" name=\"imagessort\" value=\"$key\"";
if ($config['image_sort'] == $key) {
$imgsort_dropdown .= " checked";
}
$imgsort_dropdown .= ">".$val."\n";
}
if ($cat_id != 0) {
$imgsort_dropdown .= "<input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\" />\n";
}
if (isset($show_result) && $show_result == 1) {
$imgsort_dropdown .= "<input type=\"hidden\" name=\"show_result\" value=\"1\" />\n";
}
$site_template->register_vars("imgsort_dropdown", $imgsort_dropdown);
$imgsort_dropdown_form = $site_template->parse_template("imgsort_dropdown_form");
$site_template->register_vars("imgsort_dropdown_form", $imgsort_dropdown_form);
$site_template->un_register_vars("imgsort_dropdown");
unset($imgsort_dropdown);
unset($imgsort_dropdown_form);
//-----End Images Sort Dropdown------------------------
B - Cookies based (will "remmeber" sorting options even after browser window was closed)
//-----------------------------------------------------
//--- Set Images Sort ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['imagesorder'])) {
$imagesorder = $HTTP_POST_VARS['imagesorder'];
if ($imagesorder) {
$site_sess->set_session_var("imgs_order", $imagesorder);
$session_info['imgs_order'] = $imagesorder;
}
}
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_order = isset($HTTP_COOKIE_VARS[$cookie_name.'imgs_order']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'imgs_order'])) : $config['image_order'];
$config['image_order'] = (isset($session_info['imgs_order'])) ? $session_info['imgs_order'] : $cookie_order;
$cookie_expire = time() + 60 * 60 * 24 * 90;
setcookie($cookie_name.'imgs_order', serialize($config['image_order']), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
if (isset($HTTP_POST_VARS['imagessort'])) {
$imagessort = $HTTP_POST_VARS['imagessort'];
if ($imagessort) {
$site_sess->set_session_var("imgs_sort", $imagessort);
$session_info['imgs_sort'] = $imagessort;
}
}
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_sort = isset($HTTP_COOKIE_VARS[$cookie_name.'imgs_sort']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'imgs_sort'])) : $config['image_sort'];
$config['image_sort'] = (isset($session_info['imgs_sort'])) ? $session_info['imgs_sort'] : $cookie_sort;
$cookie_expire = time() + 60 * 60 * 24 * 90;
setcookie($cookie_name.'imgs_sort', serialize($config['image_sort']), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
//----End Images Sort----------------------------------
//-----------------------------------------------------
//--- Set Images Sort Dropdown ------------------------
//-----------------------------------------------------
$imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";
foreach ($image_order_optionlist as $key => $val) {
$imgsort_dropdown .= "<option value=\"$key\"";
if ($config['image_order'] == $key) {
$imgsort_dropdown .= " selected=\"selected\"";
}
$imgsort_dropdown .= ">".$val."</option>\n";
}
$imgsort_dropdown .= "</select>\n";
foreach ($image_sort_optionlist as $key => $val) {
$imgsort_dropdown .= "<INPUT type=\"radio\" name=\"imagessort\" value=\"$key\"";
if ($config['image_sort'] == $key) {
$imgsort_dropdown .= " checked";
}
$imgsort_dropdown .= ">".$val."\n";
}
if ($cat_id != 0) {
$imgsort_dropdown .= "<input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\" />\n";
}
if (isset($show_result) && $show_result == 1) {
$imgsort_dropdown .= "<input type=\"hidden\" name=\"show_result\" value=\"1\" />\n";
}
$site_template->register_vars("imgsort_dropdown", $imgsort_dropdown);
$imgsort_dropdown_form = $site_template->parse_template("imgsort_dropdown_form");
$site_template->register_vars("imgsort_dropdown_form", $imgsort_dropdown_form);
$site_template->un_register_vars("imgsort_dropdown");
unset($imgsort_dropdown);
unset($imgsort_dropdown_form);
//-----End Images Sort Dropdown------------------------
2. Open
/lang/YOURLANGUAGE/main.php2.1. Add at the end of the file, just before
?> this code:
//--------------Images Sort-------------------------
//---This was taken from /lang/YOURLANG/admin.php---
//--------------------------------------------------
$lang['image_order'] = "Sort images by";
$image_order_optionlist = array(
"image_name" => "Name",
"image_date" => "Date",
"image_downloads" => "Downloads",
"image_votes" => "Votes",
"image_rating" => "Rating",
"image_hits" => "Hits"
);
$lang['image_sort'] = "Ascending/Descending";
$image_sort_optionlist = array(
"ASC" => "Ascending",
"DESC" => "Descending"
);
3. Create a template and save it as
imgsort_dropdown_form.html with this code:
<TABLE border="0" cellspacing="0" cellpadding="0">
<FORM method="post" action="{self}">
<TR>
<TD nowrap>{image_order} </TD>
<TD nowrap>
{imgsort_dropdown}
<INPUT type="submit" value="{lang_go}" class="button" name="submit" /></TD>
</TR>
</FORM>
</TABLE>
Now u can insert in any templates
{imgsort_dropdown_form} in the place u want show "sort images by" sellect.
U can see it in action (its on the bottom):
http://gallery.vano.org/c6