4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 01, 2014, 07:57:48 AM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [Mod] Let visitors to chose how to sort images(date,name,..)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4 5 ... 9 » »» Print
Current Topic Rating: *****
Author Topic: [Mod] Let visitors to chose how to sort images(date,name,..)  (Read 109522 times)
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 554

mmm PHP...


View Profile WWW
« on: January 29, 2003, 06:57:15 PM »

Just a thought, would be nice let visitors to chose how they want browse pictures sorted by name/date.
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 554

mmm PHP...


View Profile WWW
« Reply #1 on: January 31, 2003, 02:01:44 AM »

ok, did it myself  Rolling Eyes

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 page


1. Open /includes/page_header.php
1.1. Find:
1
 "charset" => $lang['charset'],
1.2. Add after:
1
2
 "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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-----------------------------------------------------
//--- 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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//-----------------------------------------------------
//--- 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.php
2.1. Add at the end of the file, just before ?> this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//--------------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:
1
2
3
4
5
6
7
8
9
10
<TABLE border="0" cellspacing="0" cellpadding="0">
<FORM method="post" action="{self}">
<TR>
<TD nowrap>{image_order}&nbsp;</TD>
<TD nowrap>
{imgsort_dropdown}&nbsp;
<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
« Last Edit: October 18, 2009, 09:48:42 PM by V@no » Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
deviator
Newbie
*
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #2 on: January 31, 2003, 09:40:35 PM »

WOW man, it works very well .... thanks Wink

check it out @ http://faithfulangels.com and select a category!
Logged
IngoT
Newbie
*
Offline Offline

Posts: 49

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #3 on: January 31, 2003, 10:36:32 PM »

Works very well! Thank you. Greeting Ingo.

http://www.digitalfotograf.com/bilderkiste/categories.php?cat_id=4
Logged
MrWante
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #4 on: February 04, 2003, 02:58:18 PM »

I was thinking of another sort (thing) that could be useful!
How about having an option in the edit category where you could decide the default sort that category is sorted as...

And also, an adition, sorting by image_id would also be nice... so you can have the orignal upload order...
And finally, sorting by filename, not just by image name.... (which can be changed)...

Don't these ideas make sense...???

Anyway.. I know I sure would like to see it implemented, and I am sure others would find it useful too!

Anyway, great work V@no...
Your name sure do pop up here alot! Very Happy
Logged
Chris
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4487

Thank You
-Given: 0
-Receive: 28

Did u ever stop to think and then forget to start?


View Profile
« Reply #5 on: February 04, 2003, 08:06:12 PM »

It would be perfect if someone could ehance this already nice mod to store the sort criteria in the database against the user table.  That way the last selected sort method could be used on return visits and it would persist across PCs.  Either that or store the info in a cookie.

Thanks V@no
Logged

Ernesto Taseffa
Full Member
***
Offline Offline

Posts: 151

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #6 on: February 25, 2003, 07:28:06 PM »

.
« Last Edit: August 09, 2009, 01:46:01 AM by Ernesto Taseffa » Logged
helluvaguy
Jr. Member
**
Offline Offline

Posts: 52

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #7 on: February 25, 2003, 08:07:35 PM »

Simply put the tag {imgsort_dropdown_form} in every template where you want it to appear, like search.html, category.html, and so forth.

Just put this tag within the HTML code so it is visible where you like, above or below the thumbnails or maybe even between the category-dropdown-menu and the picture per page drop-down-menu.
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 554

mmm PHP...


View Profile WWW
« Reply #8 on: February 26, 2003, 12:31:33 AM »

Quote from: Chris   [Expand]
It would be perfect if someone could ehance this already nice mod to store the sort criteria in the database against the user table.  That way the last selected sort method could be used on return visits and it would persist across PCs.  Either that or store the info in a cookie.

Thanks V@no

yes, I like this idea, but I'd like have your guys appinium, how this should work. I mean, right now my idea do it this way:

1. user can select from his control panel (profile edit) how he want sort images and how many images per page by default (whenever he closed browser and then come back).
and when he browse the site, he still has chose of image sorting, that works temporary, untill he close/open browser (just like right now, original code of this mod stay as it is and needs just little addon to it)

2. or do u want changing images sorting not from "edit user profile" will be saved directly in the database? (this case whole mod needs to be rewriten)
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
helluvaguy
Jr. Member
**
Offline Offline

Posts: 52

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #9 on: February 26, 2003, 12:47:55 AM »

I would prefer solution #2, because i use the gallery integrated into a phpBB2 forum, where the users access the user-profil from the phpBB2 and not the one from 4images.

Besides i think it would be much easier for most users to just change it without going to the user profil, eventhough it would mean a lot more work to programm it that way.

But you asked for opinons and this it mine... Smile
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 554

mmm PHP...


View Profile WWW
« Reply #10 on: February 26, 2003, 01:01:15 AM »

yes, thx. (couple more opinions and I'll start work on it Wink )

P.S. dont forget, that sort images options will still be available as it is now, it just wont be saved in the database.
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
dune
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #11 on: February 26, 2003, 05:13:03 PM »

i think it would be quite nice for users to have this as a profile option. it would also be useful to keep it in thumbnail pages display so that they don't have to go to their control panel each time they would want to change the order...
Logged
Ernesto Taseffa
Full Member
***
Offline Offline

Posts: 151

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #12 on: February 26, 2003, 05:34:38 PM »

.
« Last Edit: August 09, 2009, 01:48:37 AM by Ernesto Taseffa » Logged
tradertt
Jr. Member
**
Offline Offline

Posts: 61

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #13 on: February 27, 2003, 01:05:46 AM »

I would prefer option 2 too ...
Logged
tradertt
Jr. Member
**
Offline Offline

Posts: 61

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #14 on: February 27, 2003, 12:42:41 PM »

Can it sort by username too?  Sometimes people may want to see what a user has posted.... Kindly let me know what to add thank you Very Happy


GREAT MOD !!
Logged
Pages: [1] 2 3 4 5 ... 9 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.109 seconds with 20 queries.