4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on January 29, 2003, 06:57:15 PM

Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no 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.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on January 31, 2003, 02:01:44 AM
ok, did it myself  :roll:

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 (http://www.4homepages.de/forum/index.php?topic=3842.msg20222#msg20222)


1. Open /includes/page_header.php
1.1. Find:
Code: [Select]
 "charset" => $lang['charset'],1.2. Add after:
Code: [Select]
 "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)
Code: [Select]
//-----------------------------------------------------
//--- 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)
Code: [Select]
//-----------------------------------------------------
//--- 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:
Code: [Select]
//--------------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:
Code: [Select]
<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
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: deviator on January 31, 2003, 09:40:35 PM
WOW man, it works very well .... thanks ;)

check it out @ http://faithfulangels.com and select a category!
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: IngoT 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
Title: Great! :)
Post by: MrWante 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! :D
Title: Suggestion
Post by: Chris 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
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 25, 2003, 07:28:06 PM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: helluvaguy 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.
Title: Re: Suggestion
Post by: V@no on February 26, 2003, 12:31:33 AM
Quote from: Chris
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)
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: helluvaguy 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... :)
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 26, 2003, 01:01:15 AM
yes, thx. (couple more opinions and I'll start work on it ;) )

P.S. dont forget, that sort images options will still be available as it is now, it just wont be saved in the database.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: dune 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...
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 26, 2003, 05:34:38 PM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: tradertt on February 27, 2003, 01:05:46 AM
I would prefer option 2 too ...
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: tradertt 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 :D


GREAT MOD !!
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 27, 2003, 02:19:55 PM
Quote from: tradertt
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 :D


GREAT MOD !!

doesnt make too much sence, because u always can do search by user...
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: tradertt on February 27, 2003, 06:50:00 PM
But can it be done with a extra code? Cause I do not know what code to put in for sort by username
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 28, 2003, 12:10:29 AM
Quote from: tradertt
But can it be done with a extra code? Cause I do not know what code to put in for sort by username

8O it was simpliest change I've ever done... :?

in /lang/<yourlanguage>/main.php replace the line u inserted:
Code: [Select]
 "image_hits"      => "Hits"
with this:
Code: [Select]
 "image_hits"      => "Hits",
  "image_comments"  => "Comments",
  "user_name"       => "User"
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 28, 2003, 02:10:37 AM
hmm...I guess it wasnt so simple...this method works untill u click on image details...
if no one figure it out, then I'll try fix it in 18 hours


[EDITED]
couldnt resist... :?
in details.php u'll need do following changes:

1.
find:
Code: [Select]
if ($mode == "lightbox") {
  if (!empty($user_info['lightbox_image_ids'])) {
    $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
    $sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
            FROM ".IMAGES_TABLE."
            WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id IN (".get_auth_cat_sql("auth_viewcat").")
            ORDER BY ".$config['image_order']." ".$config['image_sort'];
    $in_mode = 1;
  }
}

replace with:
Code: [Select]
if ($mode == "lightbox") {
  if (!empty($user_info['lightbox_image_ids'])) {
    $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
    $sql = "SELECT i.image_id, i.cat_id, i.image_name, i.image_media_file, i.image_thumb_file, i.user_id
            FROM ".IMAGES_TABLE." i
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_active = 1 AND i.image_id IN ($image_id_sql) AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
            ORDER BY ".$config['image_order']." ".$config['image_sort'];
    $in_mode = 1;
  }
}



2.
Find:
Code: [Select]
 else {
    $cat_id_sql = get_auth_cat_sql("auth_viewcat");
  }

  if (!empty($sql_where_query)) {
    $sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
            FROM ".IMAGES_TABLE."
            WHERE image_active = 1
            $sql_where_query
            AND cat_id IN ($cat_id_sql)
            ORDER BY ".$config['image_order']." ".$config['image_sort'];
    $in_mode = 1;
  }
}
if (!$in_mode || empty($sql)) {
  $sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND cat_id = $cat_id
          ORDER BY ".$config['image_order']." ".$config['image_sort'];
}
$result = $site_db->query($sql);

Replace with:
Code: [Select]
 else {
    $cat_id_sql = get_auth_cat_sql("auth_viewcat");
  }

  if (!empty($sql_where_query)) {
    $sql = "SELECT i.image_id, i.cat_id, i.image_name, i.image_media_file, i.image_thumb_file, i.user_id
            FROM ".IMAGES_TABLE." i
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_active = 1
            $sql_where_query
            AND i.cat_id IN ($cat_id_sql)
            ORDER BY ".$config['image_order']." ".$config['image_sort'];
    $in_mode = 1;
  }
}
if (!$in_mode || empty($sql)) {
  $sql = "SELECT i.image_id, i.cat_id, i.image_name, i.image_media_file, i.image_thumb_file, i.user_id
          FROM ".IMAGES_TABLE." i
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1 AND i.cat_id = $cat_id
          ORDER BY ".$config['image_order']." ".$config['image_sort'];
}
$result = $site_db->query($sql);
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 28, 2003, 08:27:35 AM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 28, 2003, 09:40:44 AM
ops, sry, didnt check my post, and I had extra "feature" in my own main.php.... :oops:
just edited my post, check it again. I also added this "new feature" ;)
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 28, 2003, 10:21:47 AM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 28, 2003, 10:27:00 AM
opsy...my typo.
it's in details.php
*seems I'm the trouble here...  :? *
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 28, 2003, 10:58:55 AM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on February 28, 2003, 11:13:10 AM
geeee what's wrong with me today?  :?
sry, my bad again.
change "Hits," to this: "Hits",
I added comma in wront place...
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Ernesto Taseffa on February 28, 2003, 11:21:06 AM
.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: PuCK on March 11, 2003, 03:57:29 PM
I can't get the mod to work. I did everything like it said in the second post. I don't get anny errormessages, but when I change the options and click on go, it always shows the images by Date, Descending, like I set it up in the control panel. These options also stay selected when I click on GO.

Does anybody know why this is? It looks like it can't override the Date, Descending options wich I set up in the Control Panel.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on March 12, 2003, 12:15:19 AM
ok, I just find out why this script didnt work for me, when I uncommented two lines:
find:
Code: [Select]
//  $imagesorder = intval($HTTP_POST_VARS['imagesorder']);
Replace with:
Code: [Select]
 $imagesorder = $HTTP_POST_VARS['imagesorder'];
and find:
Code: [Select]
// $imagessort = intval($HTTP_POST_VARS['imagessort']);
Replace with:
Code: [Select]
$imagessort = $HTTP_POST_VARS['imagessort'];

that how it suposed to be :oops:

P.S. I edited my original post, so, if u just installed this MOD, then dont worry about changes above.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: PuCK on March 12, 2003, 08:55:22 AM
YES!

It works now for me to. How strange. I had those 2 lines commented, but when I changed them into the new lines you gave, uncommented it worked!  :D
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on March 12, 2003, 12:26:02 PM
Quote from: PuCK
YES!

It works now for me to. How strange. I had those 2 lines commented, but when I changed them into the new lines you gave, uncommented it worked!  :D

yes, it took me just 3 month to figure it out... hehe
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Chris on March 12, 2003, 02:33:43 PM
Programming is like that sometimes.  :wink:
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: dirk1968de on March 23, 2003, 05:05:54 PM
Hallo,

ich habe meine Galerie, wie im zweiten Beitrag beschrieben geändert. Nur kann ich keine Veränderung feststellen.

Meine Frage: Was muss ich denn jetzt noch machen?

Da ich die englische Sprache nicht beherrsche, kann ich mit den nachfolgenden Beiträgen in diesem Thread leider nichts anfangen. Kann mir denn jemand weiterhelfen?

Gruß Dirk
Title: Cookies based
Post by: V@no on March 25, 2003, 01:54:17 PM
If u want use cookies do following changes:

In the original code in the step 1.3. replace:
Code: [Select]
//-----------------------------------------------------
//--- Set Images Sort ---------------------------------
//----original script is 'Setperpage'. but it doesnt work if uncoment those two lines below ):
//----Maybe someone knows why? (;---------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['imagesorder'])) {
//  $imagesorder = intval($HTTP_POST_VARS['imagesorder']); //I dont understand why when this line uncoment, the script doesnt work?
  $imagesorder = $HTTP_POST_VARS['imagesorder']; //Added 03-11-2003
  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----------------------------------

with this:
Code: [Select]
//-----------------------------------------------------
//--- 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----------------------------------
Title: little help?
Post by: pleo on May 28, 2003, 02:49:07 AM
hi, i seem to be having a little problem with this, not sure why.  i followed the instructions and then i inserted this into category.html:
Code: [Select]
<tr>
                          <td width="80%">
                          <p align="right">{imgsort_dropdown_form}</td>
                          <td width="20%">
                          <p align="right">{upload_button}</td>
                        </tr>

but the drop down menu is not showing correctly, and i'm not sure why.
Title: Re: little help?
Post by: V@no on May 28, 2003, 02:58:36 AM
Quote from: pleo
but the drop down menu is not showing correctly, and i'm not sure why.

Please be more specific, what doesnt work? not showing correctly? what does it show? also, if u could post a link or something, could be usefull too.
Title: sorry
Post by: pleo on May 28, 2003, 03:01:20 AM
alright i'm not sure how to be more specific in words.  you can see what is happening here http://www.net-x.org/img

go to a category and look next to the "upload" button at the top. that is where the code has been inserted but all i get is a wierd little button,  thanks
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on May 28, 2003, 03:06:58 AM
ok, that was enough ;)
btw, I've never seen anything like that!
did u look at your page source code? it's pretty much....wierd...
not sure what do u use to edit .php files, or maybe it cause by something else, but the code showed with spaces between each letter!
Code: [Select]
                        <td width="80%">
                          <p align="right">&#1103;&#1102;< T A B L E   b o r d e r = " 0 "   c e l l s p a c i n g = " 0 "   c e l l p a d d i n g = " 0 " >  
         < F O R M   m e t h o d = " p o s t "   a c t i o n = "  " >  
                 < T R >  
                         < T D   n o w r a p >  & n b s p ; < / T D >  
                         < T D   n o w r a p >  
                                  & n b s p ;  
                                 < I N P U T   t y p e = " s u b m i t "   v a l u e = "  "   c l a s s = " b u t t o n "   n a m e = " s u b m i t "   / > < / T D >  
                 < / T R >  
         < / F O R M >  
 < / T A B L E > </td>
                          <td width="20%">
                          <p align="right"><img src="./templates/4dark/images/upload_off.gif" border="0" alt="" /></td>

so, hopefuly u did backup before u started do changes, restore what u did and try again...
Title: wierd
Post by: pleo on May 28, 2003, 03:19:58 AM
wierd!  something funky was going on...thanks for noticing that.  all fixed now and working lovely!!
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: artpapa on June 01, 2003, 01:28:57 AM
Hi  V@no.
I trying to install this mod, but it giving me "404 Error - File Not Found" with the this address:
http://www.artpapa.com/gallery/lang/english/%7Bself%7D

sorry I cannot describe that  better.

tx
Alexei
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 01, 2003, 01:34:52 AM
Quote from: artpapa
http://www.artpapa.com/gallery/lang/english/%7Bself%7D

seems to me u are using Macromedia Dreamweaver to edit files...
open again files u edited and replace all %7B and %7D with { and }
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: artpapa on June 01, 2003, 03:53:05 AM
thank you  
I find change only in the imgsort_dropdown_form.html, and make changes in the notepad as you provide in the mod instruction.
it is start work in the categories, but didn't work in the home template, I mean after reloading nothing is change. (Should it work in the home?).
what editor do you recommend?
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 01, 2003, 04:15:52 AM
Quote from: artpapa
it is start work in the categories, but didn't work in the home template, I mean after reloading nothing is change. (Should it work in the home?).
U must add exact same code in any templates where u want it be displayed.

Quote from: artpapa
what editor do you recommend?
Dreamweaver is very good editor, that "thing" doesnt happend all the time (atleast for me), it happend just ones in last 9 month I use it...
also, I have asked that question long time ago too ;):
http://www.4homepages.de/forum/viewtopic.php?t=1901
since then I use Ultraedit with absolutely no prblems, and I love it.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: artpapa on June 01, 2003, 04:42:35 AM
Quote from: V@no
Quote from: artpapa
it is start work in the categories, but didn't work in the home template, I mean after reloading nothing is change. (Should it work in the home?).
U must add exact same code in any templates where u want it be displayed.


Thanks, I did {imgsort_dropdown_form}, bad pictures still in the same order.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 01, 2003, 04:54:20 AM
what version of the MOD do u use? regular or with using cookies?
also, what do u mean "didnt work in the home template"? when u open index.php it shows u new images that being sorted by date, this MOD has no affect of "new images" part.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: artpapa on June 01, 2003, 05:31:05 AM
Quote from: V@no
what version of the MOD do u use? regular or with using cookies?.

for some reason I change for cookies while trying to figure out, is their any difference?

Quote from: V@no
this MOD has no affect of "new images" part.

I see, that mean not in the home.html template.

thanks a lot......
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: popo on June 03, 2003, 03:29:12 AM
but I think it's sortted images by username will be better.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 03, 2003, 03:55:51 AM
Quote from: popo
but I think it's sortted images by username will be better.

did u read all replys?
I posted the code on second page of this thread
http://www.4homepages.de/forum/viewtopic.php?t=3842
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: popo on June 03, 2003, 06:13:06 AM
oh, sorry, it worked after I read the second page.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: lutz on June 11, 2003, 01:09:48 PM
hi all,
is someone able to do this mod as a selfjump box as the ohter mods with dropdown lists? i have the category dropdown list and the images per page list as selfjump box, so this would be the only one where i have to click "go"...
i don´t know anything about php, so this is just a humble request  :wink:
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Chris on June 11, 2003, 03:06:25 PM
Be careful about making the submission of that a form a "selfjump" action.  There are two form elements, the drop down list and the radio buttons.  If I'm a user and I see that form, I'm going to think I can select something from the drop down "sort by" and then click one of the radio buttons to choose the ascending/descending.  If you make the drop down list a selfjump, I'm going to be surprised that I couldn't change the radio button.  This is a usability issue and just my two cents.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: lutz on June 11, 2003, 04:36:43 PM
ok, that´s a good consideration.
Title: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 11, 2003, 08:18:13 PM
just want to add to Chris post:
selfjump would work for dropdown, right? so, if u didnt select the order radio button and changed sort options, u'll have to chose another sort option, change order and than select again the desired sort option...
Title: sort by comments
Post by: Sheep707 on June 17, 2003, 05:15:54 PM
Ok it work, but not by sort whith comments!!!!!!

See example here: http://www.datenplatz.ch/leeger/gallery/categories.php?cat_id=9

I use the version with cookies.

???Does someone know why it dowsnt work???
Title: error message I get
Post by: comicart on June 23, 2003, 08:41:21 PM
Can anyone explain this?
I followed the instructions using the "cookie" method for part of step 1.3

I got this error message after I uploaded everything.

Code: [Select]
Parse error:  parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/comicart/public_html/gallery/lang/english/main.php on line 376
 
 Parse error:  parse error, unexpected T_VARIABLE in /home/comicart/public_html/gallery/includes/page_header.php on line 303


Terry
Title: Re: error message I get
Post by: Chris on June 23, 2003, 08:46:15 PM
Quote from: comicart
Can anyone explain this?
Code: [Select]
Parse error:  parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/comicart/public_html/gallery/lang/english/main.php on line 376
 
 Parse error:  parse error, unexpected T_VARIABLE in /home/comicart/public_html/gallery/includes/page_header.php on line 303

Sounds like you're missing a closing
Code: [Select]
)in main.php or one of the other files you modified.  Recheck the syntax of the new language variables.
Title: wow
Post by: comicart on June 23, 2003, 10:32:35 PM
Turns out what caused the error (it seems) is copy and pasting the code in SAFARI.

I switched to MOZILLA and everything works just fine.

Go figure...

T
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Vincent on March 10, 2005, 06:54:00 PM
How many changes are lost in this code  :wink:
Sincerly
vincent
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: AntiNSA2 on March 14, 2005, 02:24:11 PM
How many changes are lost in this code  :wink:
Sincerly
vincent

And, what was the best method, cookies or no cookies?

Why?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 02, 2005, 12:41:41 AM
Hello!

i have just installed the MOD.

I got radio buttons for ASC and DESC instead of a selecting menu field.

What CODE i have to change to see a selecting menu like the one of the categorie selection.
I would prefer this.

My URL:  www.industrie-gravuren.de/galerie
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 02, 2005, 12:49:50 AM
ok, u changed the code to have radio buttons instead of dropdown menu and now u want go back to dropdown instead of radio buttons?
I'm confused..
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 02, 2005, 12:58:41 AM
Sorry i was working on it and tried different codes.

Now it is working.

BUT i want to have a menu selection :!:

Do you have me an advice :?:

Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 02, 2005, 01:15:25 AM
I might, but I dont understand what exactly are u trying to do...please be more describtive.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 02, 2005, 10:11:09 AM
at V@no

ok i try to explain better. my english isn't the best.

Now you can see on my url www.industrie-gravuren.de/galerie that i have radio buttons to choose the sort direction ASC or DESC.
Instead of these buttons i would like to have a selection like the category or pics per page select.

I hope i could explain enough for you to understand me.

EDIT: I HAVE SEEN YOU HAVE WHAT I WANT TO HAVE ON YOUR URL.  The sort selecting for ASC/DESC.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 02, 2005, 02:39:23 PM
oh, I see...I didnt realize the default is radio buttons and not dropdown..
In Step 1.2 replace
Code: [Select]
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";
 }
with:
Code: [Select]
$imgsort_dropdown .= "\n<select name=\"imagessort\" class=\"setperpageselect\">\n";
 foreach ($image_sort_optionlist as $key => $val) {
   $imgsort_dropdown .= "<option value=\"$key\"";
   if ($config['image_sort'] == $key) {
     $imgsort_dropdown .= " selected=\"selected\"";
   }
   $imgsort_dropdown .= ">".$val."</option>\n";
 }
 $imgsort_dropdown .= "</select>\n";
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 02, 2005, 04:16:18 PM
Thanks v@no

Now it looks like i would have it.

 :) :D
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 02, 2005, 09:22:54 PM
at V@no

sorry, i have one more question.
i have seen on your page that you only have one "GO" Button for the two selections "sort by" and "pics per page".

This would be very kind if you could tell me the code for it, because i only have little space in the row. so it would be very good only to have one button for these selections.
And how do I become the whole line to center vertical?

Merci beaucoup.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on June 03, 2005, 01:58:41 AM
not sure if it will work, but try insert {imgsort_dropdown_form} into setperpage_dropdown_form.html template
or if it doesnt work, then insert {setperpage_dropdown} into imgsort_dropdown_form.html template (u'll need remove "go" button from setperpage_dropdown_form.html template)
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bibabobu on June 03, 2005, 11:19:19 AM
I removed the go button.
but now it is only changing the pics per page and i cannot recognize any sortation of images.

Could you give me the code of your imagesort_dropdown_form.html  and  setperpage_dropdown_form.html and also the page_header.php and lang/.../main.php

On your url its working perfect, but not for me.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Vincent on July 25, 2005, 07:31:50 PM
Thanks a lot it works!
but if i sort my country Picture and start the flashshow the flashshow will take the default i belive because i did not use cockies!

sincerly
vincent
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Nasser on October 31, 2005, 06:18:38 PM
I added this MOD
the dropdown menu of sorting images is shown in the main categore not in the sub categories in each
is it woking like that ?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Joss on January 29, 2006, 01:45:59 AM
Thanks for the MOD, V@no!

I use this MOD, but a problem that default sorting for new photos should be by date. I've made the following changes, but for certain, it is possible to write a smaller size  code (I haven't experience in PHP). :)

File: search.php

Code: [Select]
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
          FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)
          ORDER BY ".$config['image_order']." ".$config['image_sort']."
          LIMIT $offset, $perpage";

change to

Code: [Select]
  if ($search_new_images == 1) {
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
      FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
  LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
      AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)
  ORDER BY ".image_date." ".DESC."
          LIMIT $offset, $perpage";
  } else {
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
      FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
  LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
      AND c.cat_id = i.cat_id AND i.cat_id IN ($cat_id_sql)
  ORDER BY ".$config['image_order']." ".$config['image_sort']."
          LIMIT $offset, $perpage";
  }
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on January 29, 2006, 05:48:11 AM
And the simpliest way is to add above the original code block you've showed this:
Code: [Select]
  if ($search_new_images == 1)
  {
    $config['image_order'] = "image_date";
    $config['image_sort'] = "DESC";
  }
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on March 18, 2006, 12:16:40 AM
Edit search.html template
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: mawenzi on March 18, 2006, 10:29:13 PM
@ Ivan,

dass die Auswahlleiste in der Erweiterten Suche angezeigt wird macht absolut Sinn ! Denn wenn ich Bilder zu einem bestimmten Keyword suche, dann kann ich hier gleich vorgeben (z.B. Anzahl der Postkarten) wonach das Suchergebnis sortiert werden soll. Beim Upload ... da hast du Recht ... macht die Sortierungsleiste nicht unbedingt Sinn.

mawenzi
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: darvid on April 29, 2006, 09:16:41 PM
Hey,

what if i want to sort the pictures in the categories by random?

Any ideas, or did i miss a thread??

Thanks in advance,

c-bass
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: darvid on April 30, 2006, 10:08:15 AM
I found out myself, now. It might be a MOD.

Go in categories.php to line 113 an replace:

Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";

with

Code: [Select]
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$num_new_images = $config['image_cells'];
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY random_no DESC, RAND(), i.image_date DESC
        LIMIT $offset, $perpage";

Thats it!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: True4 on June 05, 2006, 12:27:47 AM
ich bekomme leider die fehlermeldung
Warning: Invalid argument supplied for foreach() in includes/page_header.php on line 462

Warning: Invalid argument supplied for foreach() in includes/page_header.php on line 470

woran kann es liegen?

danke
true4
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Fastian on September 30, 2006, 12:45:18 AM
Here is what i am trying to do.
I m not using Categories drop down so i want to have one "Go" button and what to control
"Sort Order" along with no. of pictures per page.
Here is what i have right now, but its not working at all. (Sort order doesn’t change just no. of images per page changes)
setperpage_dropdown_form
Code: [Select]
<form method="post" action="{self}">
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>{lang_images_per_page}&nbsp;</td>
      <td>{setperpage_dropdown}&nbsp;</td>
   <td>{imgsort_dropdown_form}&nbsp;&nbsp;&nbsp;
        <input type="submit" value="{lang_go}" class="button" name="submit" />
      </td>
    </tr>
  </table>
</form>

Imgsort_dropdown_form
Code: [Select]
<FORM method="post" action="{self}">
 <table border="0" cellspacing="0" cellpadding="0">
    <tr>
<TD nowrap>{image_order}&nbsp;:&nbsp;</TD>
<TD nowrap>{imgsort_dropdown}&nbsp;&nbsp;</TD>
    </tr>
 </table>
</FORM>

Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Fastian on October 12, 2006, 09:45:04 AM
Here is what i am trying to do.
I m not using Categories drop down so i want to have one "Go" button and what to control
"Sort Order" along with no. of pictures per page.
Here is what i have right now, but its not working at all. (Sort order doesn’t change just no. of images per page changes)
setperpage_dropdown_form
Code: [Select]
<form method="post" action="{self}">
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>{lang_images_per_page}&nbsp;</td>
      <td>{setperpage_dropdown}&nbsp;</td>
   <td>{imgsort_dropdown_form}&nbsp;&nbsp;&nbsp;
        <input type="submit" value="{lang_go}" class="button" name="submit" />
      </td>
    </tr>
  </table>
</form>

Imgsort_dropdown_form
Code: [Select]
<FORM method="post" action="{self}">
 <table border="0" cellspacing="0" cellpadding="0">
    <tr>
<TD nowrap>{image_order}&nbsp;:&nbsp;</TD>
<TD nowrap>{imgsort_dropdown}&nbsp;&nbsp;</TD>
    </tr>
 </table>
</FORM>


No One ??  :(
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: GhostPool on October 22, 2006, 11:12:05 PM
Is there a way to change the drop down menu to text links. For example, I would like to be able to click Name, Date, Rating etc. to sort the images. An example of this is posted here, http://www.desktopwallpapers.co.uk/desktop_wallpaper/landscapes.html

Hope someone can help! :D
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Romson on February 15, 2007, 03:22:22 PM
Hi,

i add this mod but how can i make this mod to work for new images on my index page ?

http://www.lach.tv/fun/
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: gborislav on July 13, 2007, 03:16:03 AM
Hi,

I want to add this MOD to sub_categories , so in what file to add {imgsort_dropdown_form}

thanks.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: [M]ike on July 23, 2007, 08:27:01 PM
Great Mod, used it and is working perfectly. :)
http://messengerdp.com/categories.php?cat_id=9
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on August 05, 2007, 02:02:22 AM
I'm running the code on the first page w/o any issue. I'd like to be able to sort by image_file_size though and am unsure how to edit the session code so it can do that.

Any help would be much appreciated!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on August 05, 2007, 05:55:34 AM
Do no need for session modify ... image size is no SQL but PHP from includes/functions.php file. ;)

Using GD - better result.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on October 07, 2007, 07:23:16 PM
I haven't a clue what that means, sorry.  :(

/php idiot
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on October 07, 2007, 07:26:18 PM
If for details page, use: {image_file_size} for see image filesize.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on October 07, 2007, 08:46:45 PM
Well I try adding the following to my lang file in the image sort section,

Code: [Select]
"image_file_size" => "File Size"
When I chose the option on the main page I get the following SQL error...

Code: [Select]
An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/35/d90034645/htdocs/imgdump2/includes/db_mysql.php on line 116

...and images no longer show up on the page.

My uneducated guess is that it's somehow unable to sort based on the information that's stored within {image_file_size}?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on October 07, 2007, 09:11:20 PM
Quote
Well I try adding the following to my lang file in the image sort section,

Which file you add the image_file_size for register ? I look ...
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on October 08, 2007, 12:33:34 AM
My /lang/english/main.php is here > http://www.fupushi.net/temp/main.txt

The "image_file_size" => "File Size" is down at the end.

And if you need it my

/includes/page_header.php > http://www.fupushi.net/temp/page_header.txt
/includes/sessions.php > http://www.fupushi.net/temp/sessions.txt
/includes/functions.php > http://www.fupushi.net/temp/functions.txt
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on October 08, 2007, 01:05:52 AM
Ok but ... which place in 4images you want to show this ? ... site layout (left side), details ... categories page ? Please say detail ...
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on October 08, 2007, 02:27:32 AM
Just on the categories page...

i.e. > http://imgdump.info/cat-boats-647.htm

On the categories page I have the following code chunk...

Code: [Select]
                  {if thumbnails}<br>{imgsort_dropdown_form}<br>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td>{thumbnails}</td>
                    </tr>
                  </table>
  {endif thumbnails}

I put the {imgsort_dropdown_form} within the {if thumbnails} so it doesn't display unless there are images in the category.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on October 08, 2007, 02:50:42 AM
Ok before you say file size and now is dropdown ... I no get what you try to do sorry.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on October 08, 2007, 04:03:47 AM
Well the same way that this mod allows you to sort a category of images based on image_date, image_downloads, image_votes, or image_rating I would like to sort by the file size of the images.

Just a modification to this mod as is that lets you select "File Size" from that drop down list and sort the same way as the other options.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: thunderstrike on October 08, 2007, 04:41:06 AM
File size for categories ... ?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: hoho on December 10, 2007, 05:58:46 PM
HY.

Is there a way to change the drop down menu to text links. For example, I would like to be able to click Name, Date, Rating etc. to sort the images.
An example of this is posted here, http://www.desktopwallpapers.co.uk/desktop_wallpaper/landscapes.html

Haw can i make this.

Please help.
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: malpa on January 02, 2008, 07:19:11 PM
A have installed A-version of this MOD.

But the MOD doesn't work:

User selects to sort images (there is no matter how), but after reloading of a page nothing happens: the script of the 4images takes data from the cache folder!

Only Admin can refresh the cache folder manually. After refreshing of the cache folder MOD begins to sort images.

So, users use this MOD, but they get nothing after refreshing: script shows an old version of the page with date-sorting from cache folder!

How can we solve this problem with an old version of the page in cache folder?

Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Falldog on January 16, 2008, 05:43:31 PM
File size for categories ... ?

Hmmm... let's see if I can explain this.

Let's say I have a gallery with five images.

Name       Date     Hits     Downloads     Size
Image 1     12/6     5            2             3.6MB
Image 2     6/3     100          4             1.6MB
Image 3     1/2     50            40            700KB
Image 4     3/9     10            0             10KB
Image 5    12/5     4             0             2.2MB

When you sort by hits descending while in the category the sort would go images 2, 3, 4, 1, 5.

I'd like to allow users to sort by size, where decending the order would be images 1, 5, 2, 3, 4
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Tobi.L on June 09, 2008, 11:21:17 PM
Nice Mod!
Läuft unter 1.7.6!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Daniel on July 10, 2008, 04:14:51 PM
Kann ich bestätigen. Läuft ausgezeichnet unter 1.7.6.
Danke/Thanks great!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: tennis-ecards on September 25, 2008, 04:55:47 PM
Hi, ich möchte die User nach Anzahl versendeter eCards sortieren lassen. Was muss ich ändern? Den MOD zum Zählen der Postkarten habe ich bereits installiert. (http://www.4homepages.de/forum/index.php?topic=10439.msg51881#msg51881)

Hi, how can visitors sort by number of ecards sent? I allready have this MOD installed (http://www.4homepages.de/forum/index.php?topic=10439.msg51881#msg51881)

Please help!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on September 26, 2008, 12:26:13 AM
Hi, how can visitors sort by number of ecards sent? I allready have this MOD installed (http://www.4homepages.de/forum/index.php?topic=10439.msg51881#msg51881)

Please help!
Try use this code from Step 2.1:
//--------------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",
  "image_postcards" => "Sent eCards",
);
$lang['image_sort'] = "Ascending/Descending";
$image_sort_optionlist = array(
  "ASC"  => "Ascending",
  "DESC" => "Descending"
);
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: tennis-ecards on September 27, 2008, 04:56:02 PM
it works when using this in admin.php and main.php
thanks!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Daniel on May 01, 2009, 03:46:58 PM
HI,

how i can make a LINK for the image-sort?
example: LINK for the most Hits:

<FORM method="post" action="{self}&imagesorder=image_hits&imagessort=DESC">  <INPUT type="submit" value="most seen" class="button" name="submit" /></FORM>

But it dont work. Anything Ideas?

thanks and greets
daniel
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Joss on October 28, 2009, 01:47:13 PM
A have installed A-version of this MOD.

But the MOD doesn't work:

User selects to sort images (there is no matter how), but after reloading of a page nothing happens: the script of the 4images takes data from the cache folder!

Only Admin can refresh the cache folder manually. After refreshing of the cache folder MOD begins to sort images.

So, users use this MOD, but they get nothing after refreshing: script shows an old version of the page with date-sorting from cache folder!

How can we solve this problem with an old version of the page in cache folder?



Vano, the same problem with B-version. Is there any solution for make this MOD working with category caching?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: mawenzi on October 28, 2009, 02:10:04 PM
... is deactivating of cache in global.php a solution for you ... ?
Code: [Select]
$cache_enable          = 0;
... or only ...
Code: [Select]
$cache_page_categories = 0;
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Joss on October 28, 2009, 02:20:42 PM
mawenzi,
thank you but it is temporary solution for me that I use now. At this time I've $cache_page_categories = 0; but I want to turn on it and use his MOD. :)

And also, can you say something to
http://www.4homepages.de/forum/index.php?topic=26162.0 ?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on October 28, 2009, 02:28:56 PM
in categories.php find:
    $config['template_dir'],


insert below:
    $config['image_sort'],
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Joss on October 28, 2009, 03:08:03 PM
V@no,
thanks but it is not working. Does it affect both version (A and B), I've use B?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bergblume on January 10, 2010, 07:26:28 PM
Hello together,

I use this great MOD already for a while.

I now want to know if it possible to have in a certain category (own template categories_10.htm) a fixed sorting that is pre-defined (latest added pic) by me and cannot be changed by users. In the other categories the users shall further have to possibility to sort of their own.

It would be great if I could define this in my categories_10.htm such a definition to have there always a sorting by latest added pics.

Looking forward to your solutions!

Bergblume
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on January 11, 2010, 05:21:30 AM
@Joss:
yes, it affects any versions that uses cache.


@bergblume:
Try this. in includes/page_headers.php find:
//----End Images Sort----------------------------------

insert below:
$cat_sort_force = array(
  10 => array("image_date", "DESC"),
  14 => array("image_name", "ASC"),
  31 => array("image_hits", "DESC"),
);

if (isset($cat_sort_force[$cat_id]))
{
  $config['image_order'] = $cat_sort_force[$cat_id][0];
  $config['image_sort'] = $cat_sort_force[$cat_id][1];
}


In details.php find:
show_image($image_row, $mode, 0, 1);

insert below:
if (isset($cat_sort_force[$cat_id]))
{
  $config['image_order'] = $cat_sort_force[$cat_id][0];
  $config['image_sort'] = $cat_sort_force[$cat_id][1];
}

as an example the category with ID 10 will sort images by date, ID 14 by name and ID 31 by hits
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: bergblume on January 11, 2010, 09:28:32 AM
good morning v@no!

that´s great! it works perfect!

thank you!

bergblume!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: mawenzi on January 12, 2010, 03:26:05 AM
@v@no

... the code snippet for bergblume is a nice and usefull extension ... thanks for sharing ...
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: MrAndrew on May 19, 2010, 10:28:32 PM
V@no, and how to do same thing for search_new_images=1?
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: V@no on May 20, 2010, 02:04:30 AM
V@no, and how to do same thing for search_new_images=1?
Same thing as what exactly? force specific sorting at new images page?
If yes, then in search.php and details.php find:
  if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {

Insert below:
    $config['image_order'] = "image_date";
    $config['image_sort'] = "DESC";
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: MrAndrew on May 20, 2010, 11:00:19 AM
V@no thank you very very much!!! This is what i need!!!  :D
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Lucifix on August 22, 2010, 09:00:10 PM
I've been looking in this mod and don't think its possible, but I'll ask:

is it possible to show images with most hits from last month (ORDER BY images_hits DESC && WHERE image_date > ".$last month.")

I know that i can get last month date by:
Code: [Select]
$last_month = time() - 60 * 60 * 24 * 7 * 30;
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: x23piracy on October 04, 2010, 07:45:05 PM
I've been looking in this mod and don't think its possible, but I'll ask:

is it possible to show images with most hits from last month (ORDER BY images_hits DESC && WHERE image_date > ".$last month.")

I know that i can get last month date by:
Code: [Select]
$last_month = time() - 60 * 60 * 24 * 7 * 30;

Hi,

this is sure possible but you have to build the right sql select, i cannot do this for you sorry.
But i would to say it's sure possible.


Greetz X23
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: henary on December 08, 2010, 09:10:30 PM
Hello,

i've add this MOD into my 1.7.9, it works fine!

I'm also use the MOD "Create Sort Order for each category from Admin Panel" http://www.4homepages.de/forum/index.php?topic=5026.0 and there two things different:

Use:
Code: [Select]
$cat_cache[$cat_id]['sort_field']instead of
Code: [Select]
$config['image_order']and
Code: [Select]
$cat_cache[$cat_id]['sort_order']instead of
Code: [Select]
$config['image_sort']
You have to replace two/three times each after you use the code from #2 http://www.4homepages.de/forum/index.php?topic=3842.0;msg=15861

Thank you v@no for this MOD!

Regards,
Henry

EDIT:
I would like to make combination of sorting from ACP and this MOD more perfectly! I've i use session-based user-sort, it will start by default from ACP-setting for the categorie. If user change sorting, this works fine, until session is out of date, but the user-setting now is using by any other categorie. If using Cockie-based code, the ACP-Settings have no chance  :wink:

What about this: if user change sorting order from categorie, this will be only in this categorie. If user change categorie, the default from ACP will taken until user change. May it's possible to do that?

Regards,
Henry
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: henary on December 14, 2010, 09:41:34 PM
Hello, here again and i will post you something fine  :mrgreen:

i've found the solution to combining this MOD Let visitors to chose how to sort images(date,name,..) (Sessionmode) and MOD Create Sort Order for each category from Admin Panel (http://www.4homepages.de/forum/index.php?topic=5026.0).

Now, you set up each sortorder in ACP for each category and if the user like to change, this will only used in current category - if user go into different categorie, sortorder will be by default from acp for this new categorie. And if user go back to last categorie with changed sortorder, it will be by default again - not the last state.
If go to index-page (or any other no cat page like search, lightbox ...) and back to last category, the sortorder will be at last changend state, not default from ACP.

If using highslide it will do same fine  :wink:

Please change the code from 1.3. from http://www.4homepages.de/forum/index.php?topic=3842.msg15861#msg15861

For using with MOD Create Sort Order for each category from Admin Panel
//-----------------------------------------------------
//--- Set Images Sort ---------------------------------
//-----------------------------------------------------

if ($cat_id != 0 )
 {
   $catimagesorder = $site_sess->get_session_var('catimages_order');
   if ( $catimagesorder <> $cat_id ) {
$site_sess->set_session_var('catimages_order', $cat_id);
if (isset($HTTP_POST_VARS['imagesorder'])) {
 $imagesorder = $cat_cache[$cat_id]['sort_field'];
 if ($imagesorder) {
   $site_sess->set_session_var("imgs_order", $imagesorder);
   $session_info['imgs_order'] = $imagesorder;
 }
}
if (isset($HTTP_POST_VARS['imagessort'])) {
$imagessort = $cat_cache[$cat_id]['sort_order'];
 if ($imagessort) {
   $site_sess->set_session_var("imgs_sort", $imagessort);
   $session_info['imgs_sort'] = $imagessort;
 }
}
}
else
{
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'])) {
 $cat_cache[$cat_id]['sort_field'] = $session_info['imgs_order'];
}

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;
 }
}

if (isset($session_info['imgs_sort'])) {
 $cat_cache[$cat_id]['sort_order'] = $session_info['imgs_sort'];
}
   }
}
//----End Images Sort----------------------------------


I've not tested, what will do, if you not have installed MOD Create Sort Order for each category from Admin Panel - may it works in same way but even with default sortorder by ACP for all categories.
For using without MOD Create Sort Order for each category from Admin Panel Try this code:
//-----------------------------------------------------
//--- Set Images Sort ---------------------------------
//-----------------------------------------------------

if ($cat_id != 0 )
 {
   $catimagesorder = $site_sess->get_session_var('catimages_order');
   if ( $catimagesorder <> $cat_id ) {
$site_sess->set_session_var('catimages_order', $cat_id);
if (isset($HTTP_POST_VARS['imagesorder'])) {
 $imagesorder = $config['image_order'];
 if ($imagesorder) {
   $site_sess->set_session_var("imgs_order", $imagesorder);
   $session_info['imgs_order'] = $imagesorder;
 }
}
if (isset($HTTP_POST_VARS['imagessort'])) {
$imagessort = $config['image_sort'];
 if ($imagessort) {
   $site_sess->set_session_var("imgs_sort", $imagessort);
   $session_info['imgs_sort'] = $imagessort;
 }
}
}
else
{
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 = $HTTP_POST_VARS['imagessort'];
 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----------------------------------


Please write your feedback here.

Regards,
Henry

v@no: feel free to edit or move this  :wink:
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: alvaro0022 on September 04, 2011, 09:34:04 PM
how to make work on home.html??

anyone know how to run this mod in the index and homer. Please!
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Rembrandt on September 05, 2011, 07:51:51 AM
how to make work on home.html??
...
what do you mean?
the mod works on home.html
or mean you, how sort the "New Images"? then search in index.php:
ORDER BY i.image_date DESC
and replace:
ORDER BY ".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."

Andi
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: alvaro0022 on September 05, 2011, 05:22:33 PM
That's what I wanted. thank you very much!!!

What should I add or modify to work also {setperpage_dropdown_form}??
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: Rembrandt on September 05, 2011, 06:14:33 PM
search in index.php:
LIMIT $num_new_images";
and replace:
LIMIT $perpage";
Title: Re: [Mod] Let visitors to chose how to sort images(date,name,..)
Post by: alvaro0022 on September 05, 2011, 11:57:04 PM
ooo that simple

 excuse my ignorance

 thank you very much