Author Topic: [Mod] "Images Per Page" keeps its value each visit  (Read 20944 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Mod] "Images Per Page" keeps its value each visit
« on: June 01, 2005, 01:12:33 AM »
SUMMARY

When selecting a new value for "Images Per Page", the value is only stored for the current session. If you close your browser and then open it again to the 4images site, the value you previously selected is forgotten. Only the default setting from the admin control panel is used.

This mod stores the value the user selects in a cookie so that on subsequent visits the "Images Per Page" is restored to the previously chosen setting.

COMMENTS

I chose to use a cookie and not make this part of the user's control panel for a simple reason. Many users, including me, access the same 4images web site from different computers and using monitors with different resolutions. A cookie lets me customize the "Images Per Page" to each monitor.

INSTRUCTIONS

Open includes/page_header.php and locate this block of code:
Code: [Select]

//-----------------------------------------------------
//--- Set Paging Vars ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['setperpage'])) {
  $setperpage = intval($HTTP_POST_VARS['setperpage']);
  if ($setperpage) {
    $site_sess->set_session_var("perpage", $setperpage);
    $session_info['perpage'] = $setperpage;
  }
}

if (isset($session_info['perpage'])) {
  $perpage = $session_info['perpage'];
}
else {
  $perpage = ceil($config['default_image_rows'] * $config['image_cells']);
}


REPLACE it with this block:
Code: [Select]

//-----------------------------------------------------
//--- Set Paging Vars ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['setperpage'])) {
  $setperpage = intval($HTTP_POST_VARS['setperpage']);
  if ($setperpage) {
    $site_sess->set_session_var("perpage", $setperpage);
    $session_info['perpage'] = $setperpage;
    $site_sess->set_cookie_data("perpage", $setperpage);
  }
}

if (isset($session_info['perpage'])) {
  $perpage = $session_info['perpage'];
}
else if($site_sess->read_cookie_data("perpage")) {
  $perpage = $site_sess->read_cookie_data("perpage");
  $site_sess->set_session_var("perpage", $perpage);
  $session_info['perpage'] = $perpage;
}
else {
  $perpage = ceil($config['default_image_rows'] * $config['image_cells']);
  $site_sess->set_cookie_data("perpage", $perpage);
}


That's it. Enjoy!

If you would also like to make the "Images Per Page" a jump menu, please see this post: http://www.4homepages.de/forum/index.php?topic=3815.0

Offline ruudvroon

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • AFTERTHEPARTY.NL
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #1 on: June 01, 2005, 07:22:26 AM »
I've got the error  :(
Fatal error: Call to undefined function: read_cookie_data() in /home/aftertheparty.nl/www/includes/page_header.php on line 300

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #2 on: June 01, 2005, 10:34:09 AM »
Works great! Thanks for that, it increases usability ;)
Can we use something like that in comments paging? :)
Again this addres?!
http://www.funny.lt

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #3 on: June 01, 2005, 03:12:09 PM »
Fatal error: Call to undefined function: read_cookie_data()
This is a function that is part of 4images already and it can be found inside includes/sessions.php

Either you have modified that file, unlikely, or you have missed a ; or ) or { } somewhere and this has thrown off the PHP parser.  Recheck your code very carefully, restore your clean backup files and try installing the mod again.

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #4 on: June 02, 2005, 02:32:38 PM »
It works! Thanks for this...
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline ruudvroon

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • AFTERTHEPARTY.NL
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #5 on: June 02, 2005, 04:54:35 PM »
Fatal error: Call to undefined function: read_cookie_data()
This is a function that is part of 4images already and it can be found inside includes/sessions.php

Either you have modified that file, unlikely, or you have missed a ; or ) or { } somewhere and this has thrown off the PHP parser.  Recheck your code very carefully, restore your clean backup files and try installing the mod again.
Maybe it has something to do with the phpbb intergration which I use.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #6 on: June 04, 2005, 01:14:20 AM »
That very well could be and I can only suggest that you carefully check your code for both mods.  There is never any gaurantee that 2 mods will work together and if you are not a programmer it may not be possible to locate a conflict and figure out how to fix it if it exists.  Good luck.

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #7 on: October 01, 2005, 11:31:03 PM »
um chris.
And there is no workaround the problem with phpbb?

Offline TomYork

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #8 on: February 19, 2006, 05:42:49 AM »
Excellent MOD!!  :lol:
* La prueba más clara de la sabiduría es una alegría continua...*

Offline wallpapers

  • Full Member
  • ***
  • Posts: 107
    • View Profile
    • Tuned-Cars.Net
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #9 on: February 26, 2006, 07:46:24 PM »
I installed it without any problems
it's a great mod  :D



Offline Yeti

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Bernds Homepage
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #10 on: January 07, 2007, 10:26:57 PM »
 :D and only seconds of work to make it run!!!!

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #11 on: January 08, 2007, 06:36:14 AM »
Never saw this mod, but works good!!

Thanks Chris :!: :!: (a little over due)

Offline m.a

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #12 on: February 06, 2007, 02:19:01 AM »
Hi,
Thanks Chris !

It is good Idea and nice Work!
Excellent  :idea:

m.a

Offline Yeti

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Bernds Homepage
Re: [Mod] "Images Per Page" keeps its value each visit
« Reply #13 on: April 01, 2007, 03:19:02 PM »
This Mod worked exellent with IE6 and Fire Fox. On my PC it don´t work with IE7. Has anybody an idea to make it work there to? Is it just a matter of IE7 settings???