4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Chris on June 01, 2005, 01:12:33 AM

Title: [Mod] "Images Per Page" keeps its value each visit
Post by: Chris 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
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: ruudvroon 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
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: universal 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? :)
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: Chris 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.
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: JensF on June 02, 2005, 02:32:38 PM
It works! Thanks for this...
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: ruudvroon 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.
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: Chris 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.
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: BartAfterDark on October 01, 2005, 11:31:03 PM
um chris.
And there is no workaround the problem with phpbb?
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: TomYork on February 19, 2006, 05:42:49 AM
Excellent MOD!!  :lol:
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: wallpapers on February 26, 2006, 07:46:24 PM
I installed it without any problems
it's a great mod  :D
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: Yeti on January 07, 2007, 10:26:57 PM
 :D and only seconds of work to make it run!!!!
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: CeJay on January 08, 2007, 06:36:14 AM
Never saw this mod, but works good!!

Thanks Chris :!: :!: (a little over due)
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: m.a on February 06, 2007, 02:19:01 AM
Hi,
Thanks Chris !

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

m.a
Title: Re: [Mod] "Images Per Page" keeps its value each visit
Post by: Yeti 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???